From 005ff6051b17f08f44f8a800969612f248df39b2 Mon Sep 17 00:00:00 2001 From: isidor Date: Fri, 15 Dec 2017 12:47:48 +0100 Subject: [PATCH] open editors: introduce contributable menu id --- src/vs/platform/actions/common/actions.ts | 1 + .../parts/files/electron-browser/fileActions.ts | 2 +- .../electron-browser/views/openEditorsView.ts | 15 ++++++++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/vs/platform/actions/common/actions.ts b/src/vs/platform/actions/common/actions.ts index 4f7f950ec97..e028366042a 100644 --- a/src/vs/platform/actions/common/actions.ts +++ b/src/vs/platform/actions/common/actions.ts @@ -43,6 +43,7 @@ export class MenuId { static readonly EditorTitleContext = new MenuId(); static readonly EditorContext = new MenuId(); static readonly ExplorerContext = new MenuId(); + static readonly OpenEditorsContext = new MenuId(); static readonly ProblemsPanelContext = new MenuId(); static readonly DebugVariablesContext = new MenuId(); static readonly DebugWatchContext = new MenuId(); diff --git a/src/vs/workbench/parts/files/electron-browser/fileActions.ts b/src/vs/workbench/parts/files/electron-browser/fileActions.ts index e47a8d88048..3000a7f7ee0 100644 --- a/src/vs/workbench/parts/files/electron-browser/fileActions.ts +++ b/src/vs/workbench/parts/files/electron-browser/fileActions.ts @@ -1209,7 +1209,7 @@ export class CompareResourcesAction extends Action { constructor( resource: URI, - @IWorkbenchEditorService private commandService: ICommandService, + @ICommandService private commandService: ICommandService, @IWorkspaceContextService contextService: IWorkspaceContextService, @IEnvironmentService environmentService: IEnvironmentService ) { diff --git a/src/vs/workbench/parts/files/electron-browser/views/openEditorsView.ts b/src/vs/workbench/parts/files/electron-browser/views/openEditorsView.ts index c2e52d00a2e..b7531389b47 100644 --- a/src/vs/workbench/parts/files/electron-browser/views/openEditorsView.ts +++ b/src/vs/workbench/parts/files/electron-browser/views/openEditorsView.ts @@ -40,6 +40,8 @@ import { KeyCode } from 'vs/base/common/keyCodes'; import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { ContributableActionProvider } from 'vs/workbench/browser/actions'; import { memoize } from 'vs/base/common/decorators'; +import { fillInActions } from 'vs/platform/actions/browser/menuItemActionItem'; +import { IMenuService, MenuId, IMenu } from 'vs/platform/actions/common/actions'; const $ = dom.$; @@ -55,6 +57,7 @@ export class OpenEditorsView extends ViewsViewletPanel { private listRefreshScheduler: RunOnceScheduler; private structuralRefreshDelay: number; private list: WorkbenchList; + private contributedContextMenu: IMenu; private needsRefresh: boolean; constructor( @@ -70,7 +73,8 @@ export class OpenEditorsView extends ViewsViewletPanel { @IUntitledEditorService private untitledEditorService: IUntitledEditorService, @IContextKeyService private contextKeyService: IContextKeyService, @IThemeService private themeService: IThemeService, - @ITelemetryService private telemetryService: ITelemetryService + @ITelemetryService private telemetryService: ITelemetryService, + @IMenuService menuService: IMenuService ) { super({ ...(options as IViewOptions), @@ -89,6 +93,7 @@ export class OpenEditorsView extends ViewsViewletPanel { } this.needsRefresh = false; }, this.structuralRefreshDelay); + this.contributedContextMenu = menuService.createMenu(MenuId.OpenEditorsContext, contextKeyService); // update on model changes this.disposables.push(this.model.onModelChanged(e => this.onEditorStacksModelChanged(e))); @@ -266,10 +271,14 @@ export class OpenEditorsView extends ViewsViewletPanel { private onListContextMenu(e: IListContextMenuEvent): void { const element = e.element; + const getActionsContext = () => element instanceof OpenEditor ? { group: element.editorGroup, editor: element.editorInput, resource: element.editorInput.getResource() } : { group: element }; this.contextMenuService.showContextMenu({ getAnchor: () => e.anchor, - getActions: () => this.actionProvider.getSecondaryActions(element), - getActionsContext: () => element instanceof OpenEditor ? { group: element.editorGroup, editor: element.editorInput } : { group: element } + getActions: () => this.actionProvider.getSecondaryActions(element).then(actions => { + fillInActions(this.contributedContextMenu, { arg: getActionsContext() }, actions); + return actions; + }), + getActionsContext }); } -- GitLab