diff --git a/src/vs/platform/actions/common/actions.ts b/src/vs/platform/actions/common/actions.ts index 4ae50dd5f3c..b6f363a3f67 100644 --- a/src/vs/platform/actions/common/actions.ts +++ b/src/vs/platform/actions/common/actions.ts @@ -111,25 +111,16 @@ export class MenuItemAction extends Action { return result; } - private _resource: URI; - constructor( private _item: IMenuItem, - @ICommandService private _commandService: ICommandService + @ICommandService private _commandService: ICommandService, + @IContextKeyService private _contextKeyService: IContextKeyService ) { super(MenuItemAction._getMenuItemId(_item), _item.command.title); this.order = this._item.order; //TODO@Ben order is menu item property, not an action property } - set resource(value: URI) { - this._resource = value; - } - - get resource() { - return this._resource; - } - get item(): IMenuItem { return this._item; } @@ -144,7 +135,8 @@ export class MenuItemAction extends Action { run(alt: boolean) { const {id} = alt === true && this._item.alt || this._item.command; - return this._commandService.executeCommand(id, this._resource); + const resource = this._contextKeyService.getContextKeyValue('resource'); + return this._commandService.executeCommand(id, resource); } } @@ -339,4 +331,4 @@ export class DeferredAction extends Action { } super.dispose(); } -} \ No newline at end of file +} diff --git a/src/vs/platform/actions/common/menuService.ts b/src/vs/platform/actions/common/menuService.ts index 5ee1e93c756..74d096dc3aa 100644 --- a/src/vs/platform/actions/common/menuService.ts +++ b/src/vs/platform/actions/common/menuService.ts @@ -13,7 +13,6 @@ import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/commo import { MenuId, MenuRegistry, ICommandAction, MenuItemAction, IMenu, IMenuItem, IMenuService } from 'vs/platform/actions/common/actions'; import { IExtensionService } from 'vs/platform/extensions/common/extensions'; import { ICommandService } from 'vs/platform/commands/common/commands'; -import { ResourceContextKey } from 'vs/platform/actions/common/resourceContextKey'; export class MenuService implements IMenuService { @@ -64,7 +63,7 @@ class Menu implements IMenu { group = [groupName, []]; this._menuGroups.push(group); } - group[1].push(new MenuItemAction(item, this._commandService)); + group[1].push(new MenuItemAction(item, this._commandService, this._contextKeyService)); // keep keys for eventing Menu._fillInKbExprKeys(item.when, keysFilter); @@ -100,7 +99,6 @@ class Menu implements IMenu { const activeActions: MenuItemAction[] = []; for (let action of actions) { if (this._contextKeyService.contextMatchesRules(action.item.when)) { - action.resource = ResourceContextKey.Resource.getValue(this._contextKeyService); activeActions.push(action); } } @@ -159,4 +157,4 @@ class Menu implements IMenu { // sort on titles return a.command.title.localeCompare(b.command.title); } -} \ No newline at end of file +} diff --git a/src/vs/workbench/browser/parts/editor/titleControl.ts b/src/vs/workbench/browser/parts/editor/titleControl.ts index b757f02912a..3e6817ec209 100644 --- a/src/vs/workbench/browser/parts/editor/titleControl.ts +++ b/src/vs/workbench/browser/parts/editor/titleControl.ts @@ -37,7 +37,7 @@ import { CloseEditorsInGroupAction, SplitEditorAction, CloseEditorAction, KeepEd import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { createActionItem, fillInActions } from 'vs/platform/actions/browser/menuItemActionItem'; import { IMenuService, MenuId, IMenu } from 'vs/platform/actions/common/actions'; -import { ResourceContextKey } from 'vs/platform/actions/common/resourceContextKey'; +import { ResourceContextKey } from 'vs/workbench/common/resourceContextKey'; export interface IToolbarActions { primary: IAction[]; @@ -504,4 +504,4 @@ export abstract class TitleControl implements ITitleAreaControl { // Toolbar this.editorActionsToolbar.dispose(); } -} \ No newline at end of file +} diff --git a/src/vs/platform/actions/common/resourceContextKey.ts b/src/vs/workbench/common/resourceContextKey.ts similarity index 100% rename from src/vs/platform/actions/common/resourceContextKey.ts rename to src/vs/workbench/common/resourceContextKey.ts diff --git a/src/vs/workbench/parts/files/browser/views/explorerView.ts b/src/vs/workbench/parts/files/browser/views/explorerView.ts index 20016bf8994..f554a373d9a 100644 --- a/src/vs/workbench/parts/files/browser/views/explorerView.ts +++ b/src/vs/workbench/parts/files/browser/views/explorerView.ts @@ -39,7 +39,7 @@ import { IProgressService } from 'vs/platform/progress/common/progress'; import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { IMessageService, Severity } from 'vs/platform/message/common/message'; import { RawContextKey, IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey'; -import { ResourceContextKey } from 'vs/platform/actions/common/resourceContextKey'; +import { ResourceContextKey } from 'vs/workbench/common/resourceContextKey'; export class ExplorerView extends CollapsibleViewletView { @@ -845,4 +845,4 @@ export class ExplorerView extends CollapsibleViewletView { super.dispose(); } -} \ No newline at end of file +}