Skip to content

Commit

Permalink
Pick up editor action command descriptions (#209259)
Browse files Browse the repository at this point in the history
Continuation of #193937 and #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.
  • Loading branch information
TylerLeonhardt authored Apr 1, 2024
1 parent 7d788e7 commit ade21d7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/vs/editor/contrib/quickAccess/browser/commandsQuickAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
});
}
Expand Down

0 comments on commit ade21d7

Please sign in to comment.