gpt4 book ai didi

sublimetext3 - 关闭标签页>转到上一个已编辑的标签页

转载 作者:行者123 更新时间:2023-12-03 13:35:26 25 4
gpt4 key购买 nike

当关闭sublimetext3中的选项卡时,它总是使我回到左侧,而在sublimetext2中,我被带至先前打开的一个(不一定是左侧的)。

这种行为在sublimetext2中确实非常方便,因为它创建了一种易于追溯的历史,只需先关闭标签即可。

sublimetext3中是否有相应设置?

重现步骤

  • 我打开了3个选项卡,第三个选项卡处于 Activity 状态:
    enter image description here
  • 我现在去编辑第二个:
    enter image description here
  • 我完成了并决定关闭第二个选项卡:
    enter image description here

  • 失败:我没有回到以前编辑过的:第三个

    最佳答案

    没有设置可以做到这一点。但是,由于可以使用插件完成此操作,并且我想使自己的插件编写技能保持最新水平,因此我为您编写了它。

    它称为FocusMostRecentTabClos​​er,代码位于GitHub Gist的下方和下方。

    要使用它,请将其另存为FocusMostRecentTabCloser.py目录结构中的Packages,并为focus_most_recent_tab_closer命令分配 key 。例如

    {"keys": ["ctrl+k", "ctrl+w"], "command": "focus_most_recent_tab_closer"},

    我尚未对其进行广泛的测试,它需要Sublime Text 3 build 3024或更高版本(但是现在已经相当老了)。

    如果有任何错误,请回复并发表评论,我会解决的。

    # MIT License

    import sublime
    import sublime_plugin
    import time

    LAST_FOCUS_TIME_KEY = "focus_most_recent_tab_closer_last_focused_time"

    class FocusMostRecentTabCloserCommand(sublime_plugin.TextCommand):
    """ Closes the focused view and focuses the next most recent. """

    def run(self, edit):

    most_recent = []
    target_view = None
    window = self.view.window()

    if not window.views():
    return

    for view in window.views():
    if view.settings().get(LAST_FOCUS_TIME_KEY):
    most_recent.append(view)

    most_recent.sort(key=lambda x: x.settings().get(LAST_FOCUS_TIME_KEY))
    most_recent.reverse()

    # Target the most recent but one view - the most recent view
    # is the one that is currently focused and about to be closed.

    if len(most_recent) > 1:
    target_view = most_recent[1]

    # Switch focus to the target view, this must be done before
    # close() is called or close() will shift focus to the left
    # automatically and that buffer will be activated and muck
    # up the most recently focused times.

    if target_view:
    window.focus_view(target_view)

    self.view.close()

    # If closing a view which requires a save prompt, the close()
    # call above will automatically focus the view which requires
    # the save prompt. The code below makes sure that the correct
    # view gets focused after the save prompt closes.

    if target_view and window.active_view().id() != target_view.id():
    window.focus_view(target_view)

    class FocusMostRecentTabCloserListener(sublime_plugin.EventListener):
    def on_activated(self, view):
    """ Stores the time the view is focused in the view's settings. """
    view.settings().set(LAST_FOCUS_TIME_KEY, time.time())

    关于sublimetext3 - 关闭标签页>转到上一个已编辑的标签页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52481136/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com