Skip to content

Commit eeaba7d

Browse files
authored
title - restore scoped editor service for title compute (#306699)
* title - restore scoped editor service for title compute * ccr
1 parent d10d2b4 commit eeaba7d

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import { IHoverDelegate } from '../../../../base/browser/ui/hover/hoverDelegate.
5555
import { CommandsRegistry } from '../../../../platform/commands/common/commands.js';
5656
import { safeIntl } from '../../../../base/common/date.js';
5757
import { IsCompactTitleBarContext, TitleBarVisibleContext } from '../../../common/contextkeys.js';
58+
import { ServiceCollection } from '../../../../platform/instantiation/common/serviceCollection.js';
5859

5960
export interface ITitleVariable {
6061
readonly name: string;
@@ -292,32 +293,39 @@ export class BrowserTitlebarPart extends Part implements ITitlebarPart {
292293

293294
private readonly windowTitle: WindowTitle;
294295

296+
protected readonly instantiationService: IInstantiationService;
297+
295298
constructor(
296299
id: string,
297300
targetWindow: CodeWindow,
298301
private readonly editorGroupsContainer: IEditorGroupsContainer,
299302
@IContextMenuService private readonly contextMenuService: IContextMenuService,
300303
@IConfigurationService protected readonly configurationService: IConfigurationService,
301304
@IBrowserWorkbenchEnvironmentService protected readonly environmentService: IBrowserWorkbenchEnvironmentService,
302-
@IInstantiationService protected readonly instantiationService: IInstantiationService,
305+
@IInstantiationService instantiationService: IInstantiationService,
303306
@IThemeService themeService: IThemeService,
304307
@IStorageService private readonly storageService: IStorageService,
305308
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService,
306309
@IContextKeyService protected readonly contextKeyService: IContextKeyService,
307310
@IHostService private readonly hostService: IHostService,
308-
@IEditorService private readonly editorService: IEditorService,
311+
@IEditorService editorService: IEditorService,
309312
@IMenuService private readonly menuService: IMenuService,
310313
@IKeybindingService private readonly keybindingService: IKeybindingService
311314
) {
312315
super(id, { hasTitle: false }, themeService, storageService, layoutService);
313316

317+
const scopedEditorService = editorService.createScoped(editorGroupsContainer, this._store);
318+
this.instantiationService = this._register(instantiationService.createChild(new ServiceCollection(
319+
[IEditorService, scopedEditorService]
320+
)));
321+
314322
this.isAuxiliary = targetWindow.vscodeWindowId !== mainWindow.vscodeWindowId;
315323

316324
this.isCompactContextKey = IsCompactTitleBarContext.bindTo(this.contextKeyService);
317325

318326
this.titleBarStyle = getTitleBarStyle(this.configurationService);
319327

320-
this.windowTitle = this._register(instantiationService.createInstance(WindowTitle, targetWindow));
328+
this.windowTitle = this._register(this.instantiationService.createInstance(WindowTitle, targetWindow));
321329

322330
this.hoverDelegate = this._register(createInstantHoverDelegate());
323331

@@ -713,7 +721,7 @@ export class BrowserTitlebarPart extends Part implements ITitlebarPart {
713721

714722
// The editor toolbar menu is handled by the editor group so we do not need to manage it here.
715723
// However, depending on the active editor, we need to update the context and action runner of the toolbar menu.
716-
if (this.editorActionsEnabled && this.editorService.activeEditor !== undefined) {
724+
if (this.editorActionsEnabled && this.editorGroupsContainer.activeGroup?.activeEditor) {
717725
const context: IEditorCommandsContext = { groupId: this.editorGroupsContainer.activeGroup.id };
718726

719727
this.actionToolBar.actionRunner = this.editorToolbarMenuDisposables.add(new EditorCommandsContextActionRunner(context));

0 commit comments

Comments
 (0)