From 9cf35b4eff0ff1d8bb11b55e99e3d332e98ede7e Mon Sep 17 00:00:00 2001 From: Sandeep Somavarapu Date: Mon, 26 Aug 2019 12:35:29 +0200 Subject: [PATCH] Fix #79404 --- .../preferences/browser/keybindingsEditor.ts | 20 ++++++++++++++----- .../common/keybindingsEditorModel.ts | 10 +++++----- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/vs/workbench/contrib/preferences/browser/keybindingsEditor.ts b/src/vs/workbench/contrib/preferences/browser/keybindingsEditor.ts index eb7ff5278a6..34c80e2f823 100644 --- a/src/vs/workbench/contrib/preferences/browser/keybindingsEditor.ts +++ b/src/vs/workbench/contrib/preferences/browser/keybindingsEditor.ts @@ -46,6 +46,7 @@ import { attachStylerCallback, attachInputBoxStyler } from 'vs/platform/theme/co import { IStorageService } from 'vs/platform/storage/common/storage'; import { InputBox, MessageType } from 'vs/base/browser/ui/inputbox/inputBox'; import { Emitter, Event } from 'vs/base/common/event'; +import { MenuRegistry, MenuId, isIMenuItem } from 'vs/platform/actions/common/actions'; const $ = DOM.$; @@ -489,11 +490,7 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor if (this.input) { const input: KeybindingsEditorInput = this.input as KeybindingsEditorInput; this.keybindingsEditorModel = await input.resolve(); - const editorActionsLabels: Map = EditorExtensionsRegistry.getEditorActions().reduce((editorActions, editorAction) => { - editorActions.set(editorAction.id, editorAction.label); - return editorActions; - }, new Map()); - await this.keybindingsEditorModel.resolve(editorActionsLabels); + await this.keybindingsEditorModel.resolve(this.getActionsLabels()); this.renderKeybindingsEntries(false, preserveFocus); if (input.searchOptions) { this.recordKeysAction.checked = input.searchOptions.recordKeybindings; @@ -505,6 +502,19 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor } } + private getActionsLabels(): Map { + const actionsLabels: Map = new Map(); + EditorExtensionsRegistry.getEditorActions().forEach(editorAction => actionsLabels.set(editorAction.id, editorAction.label)); + for (const menuItem of MenuRegistry.getMenuItems(MenuId.CommandPalette)) { + if (isIMenuItem(menuItem)) { + const title = typeof menuItem.command.title === 'string' ? menuItem.command.title : menuItem.command.title.value; + const category = menuItem.command.category ? typeof menuItem.command.category === 'string' ? menuItem.command.category : menuItem.command.category.value : undefined; + actionsLabels.set(menuItem.command.id, category ? `${category}: ${title}` : title); + } + } + return actionsLabels; + } + private filterKeybindings(): void { this.renderKeybindingsEntries(this.searchWidget.hasFocus()); this.delayedFilterLogging.trigger(() => this.reportFilteringUsed(this.searchWidget.getValue())); diff --git a/src/vs/workbench/services/preferences/common/keybindingsEditorModel.ts b/src/vs/workbench/services/preferences/common/keybindingsEditorModel.ts index 01bf60c346a..847b67a5bcd 100644 --- a/src/vs/workbench/services/preferences/common/keybindingsEditorModel.ts +++ b/src/vs/workbench/services/preferences/common/keybindingsEditorModel.ts @@ -160,14 +160,14 @@ export class KeybindingsEditorModel extends EditorModel { return result; } - resolve(editorActionsLabels: Map): Promise { + resolve(actionLabels: Map): Promise { const workbenchActionsRegistry = Registry.as(ActionExtensions.WorkbenchActions); this._keybindingItemsSortedByPrecedence = []; const boundCommands: Map = new Map(); for (const keybinding of this.keybindingsService.getKeybindings()) { if (keybinding.command) { // Skip keybindings without commands - this._keybindingItemsSortedByPrecedence.push(KeybindingsEditorModel.toKeybindingEntry(keybinding.command, keybinding, workbenchActionsRegistry, editorActionsLabels)); + this._keybindingItemsSortedByPrecedence.push(KeybindingsEditorModel.toKeybindingEntry(keybinding.command, keybinding, workbenchActionsRegistry, actionLabels)); boundCommands.set(keybinding.command, true); } } @@ -175,7 +175,7 @@ export class KeybindingsEditorModel extends EditorModel { const commandsWithDefaultKeybindings = this.keybindingsService.getDefaultKeybindings().map(keybinding => keybinding.command); for (const command of KeybindingResolver.getAllUnboundCommands(boundCommands)) { const keybindingItem = new ResolvedKeybindingItem(undefined, command, null, undefined, commandsWithDefaultKeybindings.indexOf(command) === -1); - this._keybindingItemsSortedByPrecedence.push(KeybindingsEditorModel.toKeybindingEntry(command, keybindingItem, workbenchActionsRegistry, editorActionsLabels)); + this._keybindingItemsSortedByPrecedence.push(KeybindingsEditorModel.toKeybindingEntry(command, keybindingItem, workbenchActionsRegistry, actionLabels)); } this._keybindingItems = this._keybindingItemsSortedByPrecedence.slice(0).sort((a, b) => KeybindingsEditorModel.compareKeybindingData(a, b)); return Promise.resolve(this); @@ -209,9 +209,9 @@ export class KeybindingsEditorModel extends EditorModel { return a.command.localeCompare(b.command); } - private static toKeybindingEntry(command: string, keybindingItem: ResolvedKeybindingItem, workbenchActionsRegistry: IWorkbenchActionRegistry, editorActions: Map): IKeybindingItem { + private static toKeybindingEntry(command: string, keybindingItem: ResolvedKeybindingItem, workbenchActionsRegistry: IWorkbenchActionRegistry, actions: Map): IKeybindingItem { const menuCommand = MenuRegistry.getCommand(command)!; - const editorActionLabel = editorActions.get(command)!; + const editorActionLabel = actions.get(command)!; return { keybinding: keybindingItem.resolvedKeybinding, keybindingItem, -- GitLab