Skip to content

fix: scope editor service in window title to own editor groups container#306226

Merged
bpasero merged 4 commits intomicrosoft:mainfrom
yogeshwaran-c:fix/window-title-after-terminal-move
Mar 30, 2026
Merged

fix: scope editor service in window title to own editor groups container#306226
bpasero merged 4 commits intomicrosoft:mainfrom
yogeshwaran-c:fix/window-title-after-terminal-move

Conversation

@yogeshwaran-c
Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

The main window's WindowTitle uses the global IEditorService, which tracks editor groups across all windows including auxiliary windows. When a terminal is moved from the panel to a new auxiliary window via "Move Terminal into New Window", the following sequence occurs:

  1. The terminal is removed from the panel group
  2. A new auxiliary editor part is created and the terminal opens as an editor there
  3. The auxiliary window gains focus
  4. The global EditorParts.activePart now returns the auxiliary part (based on getActiveDocument())
  5. The global EditorService fires onDidActiveEditorChange
  6. The main window's WindowTitle reads editorService.activeEditor, which resolves through activePart to the auxiliary window's terminal editor
  7. The main window title incorrectly updates to show the terminal name (e.g. "bash") instead of the open file

This also affects any editor moved to a new auxiliary window, not just terminals.

Closes #267538

What is the new behavior?

Each WindowTitle now receives a scoped IEditorService that only tracks editors within its own window's editor groups container. This is done by creating a child instantiation service with a scoped editor service in the BrowserTitlebarPart constructor:

  • For the main window: the editor service is scoped to editorGroupService.mainPart, so it only tracks editors in the main window
  • For auxiliary windows: the scoping is consistent with the existing approach used in auxiliaryEditorPart.ts (line 202-203), where a scoped editor service is already created for the auxiliary editor part

After the fix, moving a terminal (or any editor) to a new window no longer affects the original window's title.

Additional context

The auxiliary window's WindowTitle was already getting a correctly scoped editor service via scopedEditorPartInstantiationService (created in auxiliaryEditorPart.ts). The main window's WindowTitle was the only one using the global (unscoped) editor service, which made it susceptible to cross-window active editor changes.

The fix follows the same scoping pattern already established for auxiliary windows but applies it uniformly in BrowserTitlebarPart for all windows.

The main window's WindowTitle used the global IEditorService which
tracks editor groups across all windows including auxiliary windows.
When a terminal was moved to a new window, the auxiliary window's
active editor change propagated to the main window's title, causing
it to incorrectly display the terminal name instead of the open file.

Scope the editor service used by WindowTitle to the window's own
editor groups container so each window title only reflects editors
within that window.

Closes microsoft#267538
@vs-code-engineering
Copy link
Copy Markdown
Contributor

vs-code-engineering bot commented Mar 30, 2026

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@bpasero

Matched files:

  • src/vs/workbench/browser/parts/titlebar/titlebarPart.ts

@bpasero bpasero added this to the 1.115.0 milestone Mar 30, 2026
@bpasero bpasero requested a review from Copilot March 30, 2026 09:36
@bpasero
Copy link
Copy Markdown
Member

bpasero commented Mar 30, 2026

This is a really good catch and I wonder if this regressed, I thought I tested this back when aux windows got introduced.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes incorrect main window title updates when focus/active editor changes occur in auxiliary windows by ensuring WindowTitle reads a window-scoped IEditorService tied to that window’s editor groups container.

Changes:

  • Create a child IInstantiationService in BrowserTitlebarPart that overrides IEditorService with editorService.createScoped(editorGroupsContainer, ...).
  • Instantiate WindowTitle via the scoped instantiation service so it only tracks editors within the current window.
  • Update editor-action toolbar context gating to use editorGroupsContainer.activeGroup.activeEditor instead of the global editorService.activeEditor.

@bpasero bpasero enabled auto-merge (squash) March 30, 2026 17:05
@bpasero bpasero merged commit 4003d39 into microsoft:main Mar 30, 2026
22 checks passed
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.

Original window title incorrect after moving terminal to new window

6 participants