operations.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:hyperhelp 作者: OdatNurd 项目源码 文件源码
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")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号