Microsoft/vscode

Explicitly foregrounding a window does not mark a window as most recent for window switching (alt-backtick) on macOS

Open

#195,442 opened on Oct 12, 2023

View on GitHub
 (2 comments) (1 reaction) (1 assignee)TypeScript (10,221 forks)batch import
electronhelp wantedmacosupstreamworkbench-os-integration

Repository metrics

Stars
 (74,848 stars)
PR merge metrics
 (Avg merge 11h 43m) (1,000 merged PRs in 30d)

Description

Does this issue occur when all extensions are disabled?: Yes/No

  • VS Code Version:
  • OS Version: macOS 14.0 (23A344)

Steps to Reproduce:

  1. Run the following:
mkdir A B C D
sleep 1 && code A
sleep 1 && code B
sleep 1 && code C
sleep 1 && code D
sleep 1 && code B
  1. Use command-backtick (⌘`) to switch windows in VS Code.
  2. Use command-backtick (⌘`) to switch windows in VS Code again.

Expected

Windows come to the forefront by the most time they were explicitly foregrounded (e.g. opened via the terminal or clicked), like in all other macOS apps:

  • D
  • C

Observed

Windows come to the forefront in the following order:

  • B
  • A

This is extremely unintuitive, especially if you have windows that were created hours ago. (It feels pretty much like a random window comes to the forefront instead of the one you want.)

It would seem that one workaround might be to reload a few windows together if you want them near each other in tab order. However, using code . in the shell or the "Reload Window" command does not work. The only way I found that works is to completely close and reopen the relevant windows, which may not be practical if you have long-running shell commands that could cost minutes or hours to re-start (e.g. long-running benchmarks, which are relevant to some projects I work on).

I don't know what VS Code is doing differently, but I think it would be a lot more intuitive to macOS users if the ⌘` order matched all other apps. In particular, it would allow the very common pattern of using ⌘` and ⌘⇧` to switch between two windows repeatedly (instead of having to press ⌘` arbitrarily often) by just opening them both again e.g. from Finder.

Contributor guide