mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-02 08:15:56 +01:00
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 <benjamin.pasero@gmail.com>
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user