Repository: vscode
Issue: Focus on the Tab to the Left When Closing a Tab
Labels: feature-request,workbench-tabs

<!-- ⚠️⚠️ Do Not Delete This! bug_report_template ⚠️⚠️ -->
<!-- Please read our Rules of Conduct: https://opensource.microsoft.com/codeofconduct/ -->
<!-- 🕮 Read our guide about submitting issues: https://github.com/microsoft/vscode/wiki/Submitting-Bugs-and-Suggestions -->
<!-- 🔎 Search existing issues to avoid creating duplicates. -->
<!-- 🧪 Test using the latest Insiders build to see if your issue has already been fixed: https://code.visualstudio.com/insiders/ -->
<!-- 💡 Instead of creating your report here, use 'Report Issue' from the 'Help' menu in VS Code to pre-fill useful information. -->
<!-- 🔧 Launch with `code --disable-extensions` to check. -->
Does this issue occur when all extensions are disabled?: Yes/No

<!-- 🪓 If you answered No above, use 'Help: Start Extension Bisect' from Command Palette to try to identify the cause. -->
<!-- 📣 Issues caused by an extension need to be reported directly to the extension publisher. The 'Help > Report Issue' dialog can assist with this. -->
- VS Code Version: 1.96.2
- OS Version: NIXOS 24.11


Problem:

When I open preferences, then close them again, I am usually presented with a different tab/file than I was looking at before opening preferences (or any file/tab). This is very distracting, often to the point where I forget what I was doing. I look at this new file, confused about why it doesn't match what I'm thinking about, and by the time I figure out it's the wrong file and go through the process of getting the file I was working on back on the screen I've lost much of my focus and working memory.

For further reading on how important this sort of thing can bee, see: the principle of least surprise


Proposal:

VSCode can be made less distracting, less surprising and more predictable with an extremely simple change: focus to the left when closing a tab.

I argue that this solution is better than tracking which tabs were opened recently, because it also covers the use-case where it's been a while since the user changed focus and/or they don't remember the focus order.

It is valuable to have the interface behave in very easy to predict ways, so the user can just press some keys and not be distracted by the computer reacting in unusual (even if "smart") ways.


Use Cases:

Quick Open/Close: If the user quickly opens and closes a tab, such as settings, then closes it again they should be returned to the tab they were working on without any surprises.

After clicking on a tab: In cases where the user has recently manually switched tabs, focusing to the left is just as easy to predict as closing to the right. No harm done by this proposal.

After a long time of no focus changes: If the user has no recent memory of what tab was focused recently, the best behavior is to be easy to predict, i.e. closing to the right or left. No harm done by this proposal. Please note that this use case is made worse by having VSCode remember which tabs were open most recently and focusing the most recent one.

Closing several tabs: I want to be able to press ctrl-W several times in rapid succession, and have the tabs I expect close. This use-case is well served by focus-right (current behavior) and equally well with focus-left (my proposal) but would be terrible with focus-recent.


Conclusion:

The best user experience comes from simply focusing to the left on tab close.

Some programs implement a different focus-on-close behavior: Focusing on the most recently focused tab. I argue against this solution because it creates a worse overall experience as explained in Use Cases above.