From 4003d390fb8747be92b4e66c280584cf92579d16 Mon Sep 17 00:00:00 2001 From: Yogeshwaran C <84272111+yogeshwaran-c@users.noreply.github.com> Date: Mon, 30 Mar 2026 22:48:34 +0530 Subject: [PATCH] fix: scope editor service in window title to own editor groups container (#306226) * fix: scope editor service in window title to own editor groups container 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 #267538 * scope entire instantiator * compile * polish --------- Co-authored-by: Benjamin Pasero --- .../browser/parts/titlebar/titlebarPart.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts b/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts index a7b85c157ae..1e424bd9bb8 100644 --- a/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts +++ b/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts @@ -55,6 +55,7 @@ import { IHoverDelegate } from '../../../../base/browser/ui/hover/hoverDelegate. import { CommandsRegistry } from '../../../../platform/commands/common/commands.js'; import { safeIntl } from '../../../../base/common/date.js'; import { IsCompactTitleBarContext, TitleBarVisibleContext } from '../../../common/contextkeys.js'; +import { ServiceCollection } from '../../../../platform/instantiation/common/serviceCollection.js'; export interface ITitleVariable { readonly name: string; @@ -292,6 +293,8 @@ export class BrowserTitlebarPart extends Part implements ITitlebarPart { private readonly windowTitle: WindowTitle; + protected readonly instantiationService: IInstantiationService; + constructor( id: string, targetWindow: CodeWindow, @@ -299,25 +302,30 @@ export class BrowserTitlebarPart extends Part implements ITitlebarPart { @IContextMenuService private readonly contextMenuService: IContextMenuService, @IConfigurationService protected readonly configurationService: IConfigurationService, @IBrowserWorkbenchEnvironmentService protected readonly environmentService: IBrowserWorkbenchEnvironmentService, - @IInstantiationService protected readonly instantiationService: IInstantiationService, + @IInstantiationService instantiationService: IInstantiationService, @IThemeService themeService: IThemeService, @IStorageService private readonly storageService: IStorageService, @IWorkbenchLayoutService layoutService: IWorkbenchLayoutService, @IContextKeyService protected readonly contextKeyService: IContextKeyService, @IHostService private readonly hostService: IHostService, - @IEditorService private readonly editorService: IEditorService, + @IEditorService editorService: IEditorService, @IMenuService private readonly menuService: IMenuService, @IKeybindingService private readonly keybindingService: IKeybindingService ) { super(id, { hasTitle: false }, themeService, storageService, layoutService); + const scopedEditorService = editorService.createScoped(editorGroupsContainer, this._store); + this.instantiationService = this._register(instantiationService.createChild(new ServiceCollection( + [IEditorService, scopedEditorService] + ))); + this.isAuxiliary = targetWindow.vscodeWindowId !== mainWindow.vscodeWindowId; this.isCompactContextKey = IsCompactTitleBarContext.bindTo(this.contextKeyService); this.titleBarStyle = getTitleBarStyle(this.configurationService); - this.windowTitle = this._register(instantiationService.createInstance(WindowTitle, targetWindow)); + this.windowTitle = this._register(this.instantiationService.createInstance(WindowTitle, targetWindow)); this.hoverDelegate = this._register(createInstantHoverDelegate()); @@ -713,7 +721,7 @@ export class BrowserTitlebarPart extends Part implements ITitlebarPart { // The editor toolbar menu is handled by the editor group so we do not need to manage it here. // However, depending on the active editor, we need to update the context and action runner of the toolbar menu. - if (this.editorActionsEnabled && this.editorService.activeEditor !== undefined) { + if (this.editorActionsEnabled && this.editorGroupsContainer.activeGroup.activeEditor !== undefined) { const context: IEditorCommandsContext = { groupId: this.editorGroupsContainer.activeGroup.id }; this.actionToolBar.actionRunner = this.editorToolbarMenuDisposables.add(new EditorCommandsContextActionRunner(context));