Title: Alt-Tab away and back leaves a tab's Close button stuck showing "Close Other Editors"
Description
The new Alt+click "Close Others" tab action (#328975, #331435, #331772) can end up
visually stuck in its swapped state after switching to another application and back
with Alt-Tab, even though Alt is no longer held. Clicking the tab's close button then
closes every other tab in the group instead of the one clicked - without the user
having consciously pressed Alt at all in that moment.
Steps to Reproduce
- Open at least two editor tabs in the same group.
- Hover the mouse over one tab's close button (or leave the mouse resting over a tab
after closing/opening something there).
- Press and hold Alt, then press Tab to switch to another application (a
browser, another editor, etc.) - a normal OS-level Alt-Tab, releasing Alt only once
focus has already moved to the other application.
- Work in the other application for a moment, then switch focus back to VS Code
(click on the window, or Alt-Tab back) without moving the mouse away from the tab
bar.
- Click the close "x" on the tab that still has focus/hover from step 2.
Expected
The tab closes normally, since Alt is not being held at the moment of the click.
Actual
The tab's close icon is still showing (or reverts to showing) "Close Other Editors",
and clicking it closes every other tab in the group instead of the one clicked. This
happens silently - nothing draws the user's attention to the fact that the icon
changed meaning between steps 2-3 and step 5, so the wrong action fires without any
warning.
Suspected cause
ModifierKeyEmitter (src/vs/base/browser/dom.ts) resets altKey to false on the
window's blur event, which correctly clears the modifier state when focus leaves
VS Code. However, MultiEditorTabsControl's hoveredTabIndex
(src/vs/workbench/browser/parts/editor/multiEditorTabsControl.ts) is only cleared by
a real mouseleave on the tab - not by the window losing focus. If the mouse doesn't
physically move during the Alt-Tab round trip, the tab stays "hovered", and the
Close→Close Others swap can be retriggered without any further mouse movement, purely
by however Alt's key state is (re)established when focus returns - which is not
always reliable across applications/window managers (this area already has known
workarounds for stale Alt state, e.g. #112347, #115810).
Suggestion
Either clear hoveredTabIndex on window blur (mirroring the existing Alt-state
reset), or require the swapped "Close Others" state to be re-armed by a fresh
keydown on Alt received while VS Code has focus, rather than trusting
modifierKeyEmitter.keyStatus.altKey as a source of truth immediately after a focus
change.
Title: Alt-Tab away and back leaves a tab's Close button stuck showing "Close Other Editors"
Description
The new Alt+click "Close Others" tab action (#328975, #331435, #331772) can end up
visually stuck in its swapped state after switching to another application and back
with Alt-Tab, even though Alt is no longer held. Clicking the tab's close button then
closes every other tab in the group instead of the one clicked - without the user
having consciously pressed Alt at all in that moment.
Steps to Reproduce
after closing/opening something there).
browser, another editor, etc.) - a normal OS-level Alt-Tab, releasing Alt only once
focus has already moved to the other application.
(click on the window, or Alt-Tab back) without moving the mouse away from the tab
bar.
Expected
The tab closes normally, since Alt is not being held at the moment of the click.
Actual
The tab's close icon is still showing (or reverts to showing) "Close Other Editors",
and clicking it closes every other tab in the group instead of the one clicked. This
happens silently - nothing draws the user's attention to the fact that the icon
changed meaning between steps 2-3 and step 5, so the wrong action fires without any
warning.
Suspected cause
ModifierKeyEmitter(src/vs/base/browser/dom.ts) resetsaltKeytofalseon thewindow's
blurevent, which correctly clears the modifier state when focus leavesVS Code. However,
MultiEditorTabsControl'shoveredTabIndex(
src/vs/workbench/browser/parts/editor/multiEditorTabsControl.ts) is only cleared bya real
mouseleaveon the tab - not by the window losing focus. If the mouse doesn'tphysically move during the Alt-Tab round trip, the tab stays "hovered", and the
Close→Close Others swap can be retriggered without any further mouse movement, purely
by however Alt's key state is (re)established when focus returns - which is not
always reliable across applications/window managers (this area already has known
workarounds for stale Alt state, e.g. #112347, #115810).
Suggestion
Either clear
hoveredTabIndexon windowblur(mirroring the existing Alt-statereset), or require the swapped "Close Others" state to be re-armed by a fresh
keydownon Alt received while VS Code has focus, rather than trustingmodifierKeyEmitter.keyStatus.altKeyas a source of truth immediately after a focuschange.