Pick up editor action command descriptions (#209259)

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](7d788e70b9/src/vs/editor/contrib/comment/browser/comment.ts (L105))... and then when I search "xyz" it'll show up.
This commit is contained in:
Tyler James Leonhardt 2024-04-01 11:07:37 -04:00 committed by GitHub
parent 7d788e70b9
commit ade21d7359
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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,
});
}