提交 9cf35b4e 编写于 作者: S Sandeep Somavarapu

Fix #79404

上级 5e13837b
...@@ -46,6 +46,7 @@ import { attachStylerCallback, attachInputBoxStyler } from 'vs/platform/theme/co ...@@ -46,6 +46,7 @@ import { attachStylerCallback, attachInputBoxStyler } from 'vs/platform/theme/co
import { IStorageService } from 'vs/platform/storage/common/storage'; import { IStorageService } from 'vs/platform/storage/common/storage';
import { InputBox, MessageType } from 'vs/base/browser/ui/inputbox/inputBox'; import { InputBox, MessageType } from 'vs/base/browser/ui/inputbox/inputBox';
import { Emitter, Event } from 'vs/base/common/event'; import { Emitter, Event } from 'vs/base/common/event';
import { MenuRegistry, MenuId, isIMenuItem } from 'vs/platform/actions/common/actions';
const $ = DOM.$; const $ = DOM.$;
...@@ -489,11 +490,7 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor ...@@ -489,11 +490,7 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
if (this.input) { if (this.input) {
const input: KeybindingsEditorInput = this.input as KeybindingsEditorInput; const input: KeybindingsEditorInput = this.input as KeybindingsEditorInput;
this.keybindingsEditorModel = await input.resolve(); this.keybindingsEditorModel = await input.resolve();
const editorActionsLabels: Map<string, string> = EditorExtensionsRegistry.getEditorActions().reduce((editorActions, editorAction) => { await this.keybindingsEditorModel.resolve(this.getActionsLabels());
editorActions.set(editorAction.id, editorAction.label);
return editorActions;
}, new Map<string, string>());
await this.keybindingsEditorModel.resolve(editorActionsLabels);
this.renderKeybindingsEntries(false, preserveFocus); this.renderKeybindingsEntries(false, preserveFocus);
if (input.searchOptions) { if (input.searchOptions) {
this.recordKeysAction.checked = input.searchOptions.recordKeybindings; this.recordKeysAction.checked = input.searchOptions.recordKeybindings;
...@@ -505,6 +502,19 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor ...@@ -505,6 +502,19 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
} }
} }
private getActionsLabels(): Map<string, string> {
const actionsLabels: Map<string, string> = new Map<string, string>();
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 { private filterKeybindings(): void {
this.renderKeybindingsEntries(this.searchWidget.hasFocus()); this.renderKeybindingsEntries(this.searchWidget.hasFocus());
this.delayedFilterLogging.trigger(() => this.reportFilteringUsed(this.searchWidget.getValue())); this.delayedFilterLogging.trigger(() => this.reportFilteringUsed(this.searchWidget.getValue()));
......
...@@ -160,14 +160,14 @@ export class KeybindingsEditorModel extends EditorModel { ...@@ -160,14 +160,14 @@ export class KeybindingsEditorModel extends EditorModel {
return result; return result;
} }
resolve(editorActionsLabels: Map<string, string>): Promise<EditorModel> { resolve(actionLabels: Map<string, string>): Promise<EditorModel> {
const workbenchActionsRegistry = Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions); const workbenchActionsRegistry = Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions);
this._keybindingItemsSortedByPrecedence = []; this._keybindingItemsSortedByPrecedence = [];
const boundCommands: Map<string, boolean> = new Map<string, boolean>(); const boundCommands: Map<string, boolean> = new Map<string, boolean>();
for (const keybinding of this.keybindingsService.getKeybindings()) { for (const keybinding of this.keybindingsService.getKeybindings()) {
if (keybinding.command) { // Skip keybindings without commands 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); boundCommands.set(keybinding.command, true);
} }
} }
...@@ -175,7 +175,7 @@ export class KeybindingsEditorModel extends EditorModel { ...@@ -175,7 +175,7 @@ export class KeybindingsEditorModel extends EditorModel {
const commandsWithDefaultKeybindings = this.keybindingsService.getDefaultKeybindings().map(keybinding => keybinding.command); const commandsWithDefaultKeybindings = this.keybindingsService.getDefaultKeybindings().map(keybinding => keybinding.command);
for (const command of KeybindingResolver.getAllUnboundCommands(boundCommands)) { for (const command of KeybindingResolver.getAllUnboundCommands(boundCommands)) {
const keybindingItem = new ResolvedKeybindingItem(undefined, command, null, undefined, commandsWithDefaultKeybindings.indexOf(command) === -1); 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)); this._keybindingItems = this._keybindingItemsSortedByPrecedence.slice(0).sort((a, b) => KeybindingsEditorModel.compareKeybindingData(a, b));
return Promise.resolve(this); return Promise.resolve(this);
...@@ -209,9 +209,9 @@ export class KeybindingsEditorModel extends EditorModel { ...@@ -209,9 +209,9 @@ export class KeybindingsEditorModel extends EditorModel {
return a.command.localeCompare(b.command); return a.command.localeCompare(b.command);
} }
private static toKeybindingEntry(command: string, keybindingItem: ResolvedKeybindingItem, workbenchActionsRegistry: IWorkbenchActionRegistry, editorActions: Map<string, string>): IKeybindingItem { private static toKeybindingEntry(command: string, keybindingItem: ResolvedKeybindingItem, workbenchActionsRegistry: IWorkbenchActionRegistry, actions: Map<string, string>): IKeybindingItem {
const menuCommand = MenuRegistry.getCommand(command)!; const menuCommand = MenuRegistry.getCommand(command)!;
const editorActionLabel = editorActions.get(command)!; const editorActionLabel = actions.get(command)!;
return <IKeybindingItem>{ return <IKeybindingItem>{
keybinding: keybindingItem.resolvedKeybinding, keybinding: keybindingItem.resolvedKeybinding,
keybindingItem, keybindingItem,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册