From 1e44d1df0a98dfbe6a43718840ef8429c0526ef4 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Mon, 1 Apr 2024 10:48:15 -0400 Subject: [PATCH] Pick up editor action command descriptions Continuation of https://github.com/microsoft/vscode/pull/193937 and https://github.com/microsoft/vscode/pull/197442 This adds the command descriptions of editor actions to the ICommandQuickPick results so that those results can be picked up by the "similar commands" feature. Example: I can add: ``` metadata: { description: nls.localize2('test', "xyz"), } ``` to the [AddLineCommentAction](https://github.com/microsoft/vscode/blob/7d788e70b95c79718b565ff9e255858db4cc74b3/src/vs/editor/contrib/comment/browser/comment.ts#L105)... and then when I search "xyz" it'll show up. --- .../quickAccess/browser/commandsQuickAccess.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/vs/editor/contrib/quickAccess/browser/commandsQuickAccess.ts b/src/vs/editor/contrib/quickAccess/browser/commandsQuickAccess.ts index 9b91b082ab640..9334d7fcde124 100644 --- a/src/vs/editor/contrib/quickAccess/browser/commandsQuickAccess.ts +++ b/src/vs/editor/contrib/quickAccess/browser/commandsQuickAccess.ts @@ -5,6 +5,8 @@ import { stripIcons } from 'vs/base/common/iconLabels'; import { IEditor } from 'vs/editor/common/editorCommon'; +import { ILocalizedString } from 'vs/nls'; +import { isLocalizedString } from 'vs/platform/action/common/action'; import { ICommandService } from 'vs/platform/commands/common/commands'; import { IDialogService } from 'vs/platform/dialogs/common/dialogs'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; @@ -38,9 +40,18 @@ export abstract class AbstractEditorCommandsQuickAccessProvider extends Abstract const editorCommandPicks: ICommandQuickPick[] = []; for (const editorAction of activeTextEditorControl.getSupportedActions()) { + let commandDescription: undefined | ILocalizedString; + if (editorAction.metadata?.description) { + if (isLocalizedString(editorAction.metadata.description)) { + commandDescription = editorAction.metadata.description; + } else { + commandDescription = { original: editorAction.metadata.description, value: editorAction.metadata.description }; + } + } editorCommandPicks.push({ commandId: editorAction.id, commandAlias: editorAction.alias, + commandDescription, label: stripIcons(editorAction.label) || editorAction.id, }); }