facelessuser / TabsExtra

Sublime Plugin with sticky tabs, more tab closing options, and additional menu items.
https://facelessuser.github.io/TabsExtra/
MIT License
107 stars 10 forks source link

The neighboring tab is also selected when closing an inactive tab #50

Closed evandrocoan closed 7 years ago

evandrocoan commented 7 years ago

Originally posted on:

  1. https://github.com/SublimeTextIssues/Core/issues/1917

Initially I tough it was Sublime Text fault, but after studying it better I narrowed it down to this package.

Summary

When I got like 3 tabs opened, and I am focused on tab number 3, and close the tab number 1, the tab number 2 is focused (bad):

back

Expected behavior

On this case, Sublime Text should not change my current tab. My current tab should stay focused. Just because I am closing another unfocused tab, my current tab focus should not be changed to the neighboring tab mentioned on the change log:

Changed tab close behavior: the neighboring tab is now always selected

https://www.sublimetext.com/2to3

Actual behavior

Sublime Text is changing my current focused tab, when some unfocused tab is closed. If this the desired behavior, I would like a setting to disable this, as it is somewhat annoying.

Steps to reproduce

  1. Create 3 tabs.
  2. Select the tabs 1, 2, and 3 respectevily.
  3. Close tab 1.
  4. Now tab 2 will be focused, but tab 3 should stay on focus.

Environment


Related issues:

  1. https://github.com/facelessuser/TabsExtra/issues/44 Tab focusing
facelessuser commented 7 years ago

Please post TabExtra settings.

evandrocoan commented 7 years ago
{
    // By default TabsExtra forgets a tab's "stickiness" when
    // any "tab close" command is issued.  You can make the tab's
    // "Stickiness" persist by enabling the following feature.
    "persistent_sticky": true,

    // If active window gets closed, default to (left|right|last_active)
    "fallback_focus": "right",

    // Experimental: When opening a view, where should it be spawned at (none|left|active_left|active_right|right)
    "spawn_view": "none",

    // Menu layout include or exclude, in whatever order you desire, the following options:
    // ["close", "sticky", "open", "clone", "save", "delete", "rename", "reveal", "path", "revert", "sort"]
    // When done, go to Preferences->Package Settings->TabsExtra and Install/Upgrade either
    // the default TabsMenu or the Override Menu which overrides the "Default" package's menu.
    "menu_layout": ["open", "save", "delete", "rename", "revert"],

    // Define sort layout.  Each entry contains:
    //    "module": plugin that defines what view meta data is used to sort
    //    "caption": menu name for entry
    //    "reverse": (optional) sort tabs in the reverse (true|false)
    "sort_layout": [
        {"module": "TabsExtra.sort.name", "caption": "Name"},
        {"module": "TabsExtra.sort.path", "caption": "Path"},
        {"module": "TabsExtra.sort.modified", "caption": "Modified"},
        {"module": "TabsExtra.sort.created", "caption": "Created"},
        {"module": "TabsExtra.sort.type", "caption": "Extension"},
        {"module": "TabsExtra.sort.size", "caption": "Size"},
        {"module": "TabsExtra.sort.activated", "caption": "Last Activated"},
        {"module": "TabsExtra.sort.syntax", "caption": "Syntax"},
        {"module": "TabsExtra.sort.reverse", "caption": "Reverse Order"}
    ],

    // When sorting, normal strings will be sorted numerically.
    //
    // Example (non-numerical sort):
    //   test12 test2 test1 => test1 test12 test2
    //
    // Example (numerical sort):
    //   test12 test2 test1 => test1 test2 test12
    "numeric_sort": false,

    // Sort tabs when a file is opened or saved
    "sort_on_load_save": false,

    // Sort module to use when sorting on load and save
    //    "module": plugin that defines what view meta data is used to sort
    //    "reverse": (optional) sort tabs in the reverse (true|false)
    "sort_on_load_save_command": {"module": "TabsExtra.sort.name"}
}
facelessuser commented 7 years ago

Did you notice the fallback_focus setting? Tab Extra does have known focus side effects, but this isn't one of them.

evandrocoan commented 7 years ago

😱 I set it to "fallback_focus": "last_active", and it stopped doing that!

But it says If active window gets closed, not view?

facelessuser commented 7 years ago

I mess up my documentation a lot.

facelessuser commented 7 years ago

Hopefully it is correct on the official doc site.

evandrocoan commented 7 years ago

Uhum, thanks! This feature solves this feature request on the Sublime Text core:

  1. https://github.com/SublimeTextIssues/Core/issues/1918 Respect the MRU (Most Recently Used) when closing tabs
evandrocoan commented 7 years ago

But I think it seems a bug, because it is changing the current view focus to left|right when some third unfocused view is closed, and the setting fallback_focus is set to left|right. When the setting fallback_focus is set to last_active it does indeed works correctly for these cases.

evandrocoan commented 7 years ago

It should change to left|right only when the current view is closed, not some unfocused one.

facelessuser commented 7 years ago

Is it different when clicking the x vs right clicking the tab and selecting close?

evandrocoan commented 7 years ago

It is not closing when I select close. This is my close command entry:

    { "command": "close_by_index", "args": { "group": -1, "index": -1 }, "caption": "Close" },
evandrocoan commented 7 years ago

Update:

I just noticed I had did bulk packages enable/disable while I was looking for the package creating this behavior, and the menus entries were not working correctly.

I after restarting Sublime Text, it started working again. When I close with the menu, it is working correctly.

evandrocoan commented 7 years ago

back

facelessuser commented 7 years ago

I after restarting Sublime Text, it started working again. When I close with the menu, it is working correctly.

Great this is expected. The reason why the x closing doesn't work is because I cannot override that close behavior. The x button uses a close method that does not pass through the API, so I cannot fix that unfortunately. Tab focusing is a big hack, and as mentioned before, there are some side effects tracked in #44, and there are some issues I just cannot fix.

evandrocoan commented 7 years ago

I opened an issue on Sublime Text Core, asking about this fix.

facelessuser commented 7 years ago

As there is currently no actionable item here, I will close this issue.