From 5a53b4db1ef772c4a84cbda87e23b06f50f5fcde Mon Sep 17 00:00:00 2001 From: Sandeep Somavarapu Date: Wed, 11 Mar 2020 12:36:23 +0100 Subject: [PATCH] minimize changes --- .../actions/browser/menuEntryActionViewItem.ts | 12 ++++++------ src/vs/platform/actions/common/actions.ts | 13 +++++++------ .../contrib/quickopen/browser/commandsHandler.ts | 2 +- .../remote/electron-browser/remote.contribution.ts | 2 +- src/vs/workbench/electron-browser/window.ts | 4 ++-- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/vs/platform/actions/browser/menuEntryActionViewItem.ts b/src/vs/platform/actions/browser/menuEntryActionViewItem.ts index 41260c2dc6e..4e3e1dec7a2 100644 --- a/src/vs/platform/actions/browser/menuEntryActionViewItem.ts +++ b/src/vs/platform/actions/browser/menuEntryActionViewItem.ts @@ -12,7 +12,7 @@ import { IdGenerator } from 'vs/base/common/idGenerator'; import { IDisposable, toDisposable, MutableDisposable, DisposableStore } from 'vs/base/common/lifecycle'; import { isLinux, isWindows } from 'vs/base/common/platform'; import { localize } from 'vs/nls'; -import { IMenu, IMenuActionOptions, MenuItemAction, SubmenuItemAction, Icon } from 'vs/platform/actions/common/actions'; +import { ICommandAction, IMenu, IMenuActionOptions, MenuItemAction, SubmenuItemAction, Icon } from 'vs/platform/actions/common/actions'; import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { INotificationService } from 'vs/platform/notification/common/notification'; @@ -171,7 +171,7 @@ export class MenuEntryActionViewItem extends ActionViewItem { render(container: HTMLElement): void { super.render(container); - this._updateItemClass(this._action); + this._updateItemClass(this._action.item); let mouseOver = false; @@ -227,18 +227,18 @@ export class MenuEntryActionViewItem extends ActionViewItem { if (this.options.icon) { if (this._commandAction !== this._action) { if (this._action.alt) { - this._updateItemClass(this._action.alt); + this._updateItemClass(this._action.alt.item); } } else if ((this._action).alt) { - this._updateItemClass(this._action); + this._updateItemClass(this._action.item); } } } - _updateItemClass(item: MenuItemAction): void { + _updateItemClass(item: ICommandAction): void { this._itemClassDispose.value = undefined; - const icon = item.checked && (item.item.toggled as { icon?: Icon })?.icon ? (item.item.toggled as { icon: Icon }).icon : item.item.icon; + const icon = this._commandAction.checked && (item.toggled as { icon?: Icon })?.icon ? (item.toggled as { icon: Icon }).icon : item.icon; if (ThemeIcon.isThemeIcon(icon)) { // theme icons diff --git a/src/vs/platform/actions/common/actions.ts b/src/vs/platform/actions/common/actions.ts index 0cf822b0156..ef6c4eb014e 100644 --- a/src/vs/platform/actions/common/actions.ts +++ b/src/vs/platform/actions/common/actions.ts @@ -277,14 +277,14 @@ export class MenuItemAction extends ExecuteCommandAction { @IContextKeyService contextKeyService: IContextKeyService, @ICommandService commandService: ICommandService ) { - super(item.id, typeof item.title === 'string' ? item.title : item.title.value, commandService); - this.item = item; + typeof item.title === 'string' ? super(item.id, item.title, commandService) : super(item.id, item.title.value, commandService); + this._cssClass = undefined; - this._enabled = !this.item.precondition || contextKeyService.contextMatchesRules(this.item.precondition); - this._tooltip = this.item.tooltip ? typeof this.item.tooltip === 'string' ? this.item.tooltip : this.item.tooltip.value : undefined; + this._enabled = !item.precondition || contextKeyService.contextMatchesRules(item.precondition); + this._tooltip = item.tooltip ? typeof item.tooltip === 'string' ? item.tooltip : item.tooltip.value : undefined; - if (this.item.toggled) { - const toggled = ((this.item.toggled as { condition: ContextKeyExpression }).condition ? this.item.toggled : { condition: this.item.toggled }) as { + if (item.toggled) { + const toggled = ((item.toggled as { condition: ContextKeyExpression }).condition ? item.toggled : { condition: item.toggled }) as { condition: ContextKeyExpression, icon?: Icon, tooltip?: string | ILocalizedString }; this._checked = contextKeyService.contextMatchesRules(toggled.condition); @@ -295,6 +295,7 @@ export class MenuItemAction extends ExecuteCommandAction { this._options = options || {}; + this.item = item; this.alt = alt ? new MenuItemAction(alt, undefined, this._options, contextKeyService, commandService) : undefined; } diff --git a/src/vs/workbench/contrib/quickopen/browser/commandsHandler.ts b/src/vs/workbench/contrib/quickopen/browser/commandsHandler.ts index 8754e487ff4..de09fec3d45 100644 --- a/src/vs/workbench/contrib/quickopen/browser/commandsHandler.ts +++ b/src/vs/workbench/contrib/quickopen/browser/commandsHandler.ts @@ -591,7 +591,7 @@ export class CommandsHandler extends QuickOpenHandler implements IDisposable { const aliasHighlights = alias ? wordFilter(searchValue, alias) : null; if (labelHighlights || aliasHighlights) { - entries.push(this.instantiationService.createInstance(ActionCommandEntry, action.id, this.keybindingService.lookupKeybinding(action.id), label, alias, { label: labelHighlights, alias: aliasHighlights }, action, (id: string) => this.onBeforeRunCommand(id))); + entries.push(this.instantiationService.createInstance(ActionCommandEntry, action.item.id, this.keybindingService.lookupKeybinding(action.id), label, alias, { label: labelHighlights, alias: aliasHighlights }, action, (id: string) => this.onBeforeRunCommand(id))); } } } diff --git a/src/vs/workbench/contrib/remote/electron-browser/remote.contribution.ts b/src/vs/workbench/contrib/remote/electron-browser/remote.contribution.ts index 66e33929be5..67df9f76198 100644 --- a/src/vs/workbench/contrib/remote/electron-browser/remote.contribution.ts +++ b/src/vs/workbench/contrib/remote/electron-browser/remote.contribution.ts @@ -207,7 +207,7 @@ export class RemoteWindowActiveIndicator extends Disposable implements IWorkbenc } items.push({ type: 'item', - id: action.id, + id: action.item.id, label }); } diff --git a/src/vs/workbench/electron-browser/window.ts b/src/vs/workbench/electron-browser/window.ts index d5e9340d412..6f7117b9068 100644 --- a/src/vs/workbench/electron-browser/window.ts +++ b/src/vs/workbench/electron-browser/window.ts @@ -23,7 +23,7 @@ import { IResourceEditorInput } from 'vs/platform/editor/common/editor'; import { KeyboardMapperFactory } from 'vs/workbench/services/keybinding/electron-browser/nativeKeymapService'; import { ipcRenderer as ipc, webFrame, crashReporter, CrashReporterStartOptions, Event as IpcEvent } from 'electron'; import { IWorkspaceEditingService } from 'vs/workbench/services/workspaces/common/workspaceEditing'; -import { IMenuService, MenuId, IMenu, MenuItemAction, SubmenuItemAction, MenuRegistry, ICommandAction } from 'vs/platform/actions/common/actions'; +import { IMenuService, MenuId, IMenu, MenuItemAction, ICommandAction, SubmenuItemAction, MenuRegistry } from 'vs/platform/actions/common/actions'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { createAndFillInActionBarActions } from 'vs/platform/actions/browser/menuEntryActionViewItem'; import { RunOnceScheduler } from 'vs/base/common/async'; @@ -511,7 +511,7 @@ export class NativeWindow extends Disposable { // Command if (action instanceof MenuItemAction) { - if (ignoredItems.indexOf(action.id) >= 0) { + if (ignoredItems.indexOf(action.item.id) >= 0) { continue; // ignored } -- GitLab