Skip to content

Commit 5002e8a

Browse files
authored
Add keybindings to the internal get all commands function (microsoft#181918)
Add keybindings to the command index
1 parent 5f04425 commit 5002e8a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/vs/workbench/contrib/preferences/browser/preferencesActions.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { Registry } from 'vs/platform/registry/common/platform';
1616
import { Extensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry';
1717
import { EditorExtensionsRegistry } from 'vs/editor/browser/editorExtensions';
1818
import { MenuId, MenuRegistry, isIMenuItem } from 'vs/platform/actions/common/actions';
19+
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
1920

2021
export class ConfigureLanguageBasedSettingsAction extends Action {
2122

@@ -80,17 +81,20 @@ CommandsRegistry.registerCommand({
8081
});
8182

8283
//#region --- Register a command to get all actions from the command palette
83-
CommandsRegistry.registerCommand('_getAllCommands', function () {
84-
const actions: { command: string; label: string; precondition?: string }[] = [];
84+
CommandsRegistry.registerCommand('_getAllCommands', function (accessor) {
85+
const keybindingService = accessor.get(IKeybindingService);
86+
const actions: { command: string; label: string; precondition?: string; keybinding: string }[] = [];
8587
for (const editorAction of EditorExtensionsRegistry.getEditorActions()) {
86-
actions.push({ command: editorAction.id, label: editorAction.label, precondition: editorAction.precondition?.serialize() });
88+
const keybinding = keybindingService.lookupKeybinding(editorAction.id);
89+
actions.push({ command: editorAction.id, label: editorAction.label, precondition: editorAction.precondition?.serialize(), keybinding: keybinding?.getLabel() ?? 'Not set' });
8790
}
8891
for (const menuItem of MenuRegistry.getMenuItems(MenuId.CommandPalette)) {
8992
if (isIMenuItem(menuItem)) {
9093
const title = typeof menuItem.command.title === 'string' ? menuItem.command.title : menuItem.command.title.value;
9194
const category = menuItem.command.category ? typeof menuItem.command.category === 'string' ? menuItem.command.category : menuItem.command.category.value : undefined;
9295
const label = category ? `${category}: ${title}` : title;
93-
actions.push({ command: menuItem.command.id, label, precondition: menuItem.when?.serialize() });
96+
const keybinding = keybindingService.lookupKeybinding(menuItem.command.id);
97+
actions.push({ command: menuItem.command.id, label, precondition: menuItem.when?.serialize(), keybinding: keybinding?.getLabel() ?? 'Not set' });
9498
}
9599
}
96100
return actions;

0 commit comments

Comments
 (0)