Skip to content

Show maximized auxiliary windows after restore - #351274

Open
Adi1231234 wants to merge 1 commit into
microsoft:mainfrom
Adi1231234:fix-maximized-aux-window-restore
Open

Adi1231234 wants to merge 1 commit into
microsoft:mainfrom
Adi1231234:fix-maximized-aux-window-restore

Conversation

@Adi1231234

Copy link
Copy Markdown

Fixes #330650

If an auxiliary window is maximized when VS Code closes, it comes back hidden on the next start.

AuxiliaryWindow calls tryClaimWindow() from its constructor, which runs on web-contents-created. At that point BrowserWindow.fromWebContents() still returns nothing, so _win is undefined. Since d1e225f that call falls back to this.windowOptions and runs applyState() right away. maximize() and show() do nothing without a window, but stateApplied is already true, so when the window is claimed on browser-window-created the state is not applied again. A window restored as maximized is created with show: false, so nothing ever shows it.

That also explains the alternating pattern people describe in the issue: after a failed restore the window is saved as not maximized, so the next start works.

If you then open an editor that lives in that window, moveWindowTop() calls moveTop() on it. That makes the window visible to the OS without Chromium showing it, so it never paints and you get an empty window in the background color.

The fix only applies the state once the window has been claimed.

Tested on 1.147.0 on Windows by applying the same change to the built main bundle:

  • a window saved as maximized now restores visible and maximized, and paints
  • before the change it restored hidden, and after moveTop() it stayed unpainted
  • opening a normal (not maximized) auxiliary window works as before

The state of an auxiliary window was applied from the constructor,
before the BrowserWindow could be claimed, so maximize() and show()
had no window to act on and the state was never applied again. A
window restored as maximized is created hidden and stayed hidden.

Fixes microsoft#330650
Copilot AI balanced review requested due to automatic review settings November 30, 2026 18:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the change that defers saved-state application until the auxiliary window is available.

No open issues 🎉

What changed in this PR

Fixes hidden maximized auxiliary windows on restart by waiting until the Electron window has been claimed before applying its saved state.

Changes:

  • Requires _win to exist before applying state, preserving the later opportunity to maximize and show the window.
  • Adds a comment explaining why applying state too early leaves hidden windows invisible.
File Description
src/​vs/​platform/​auxiliaryWindow/​electron-main/​auxiliaryWindow.ts Defers saved-state application until the auxiliary window is available.

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auxiliary window sometimes fails to restore after being maximized on multi-monitor setup

2 participants