mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
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:
parent
7d788e70b9
commit
ade21d7359
|
@ -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,
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue