def focus_on(view, position):
"""
Focus the given help view on the provided position to ensure that is is
visible. This alters the selection to the given position.
If position is a point, the view is focused on that point and the cursor is
placed there. If it is a Region, the region is selected and the cursor is
left at the beginning of the region instead of at the end.
"""
if isinstance(position, int):
position = sublime.Region(position, position)
else:
position = sublime.Region(position.end(), position.begin())
view.show_at_center(position)
view.sel().clear()
view.sel().add(position)
# Hack to make the view update properly. See:
# https://github.com/SublimeTextIssues/Core/issues/485
view.add_regions("_hh_rk", [], "", "", sublime.HIDDEN)
view.erase_regions("_hh_rk")
评论列表
文章目录