mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 21:55:38 +00:00
Allow to pass language mode for workbench.action.editor.changeLanguageMode
action (fix #213688) (#213912)
This commit is contained in:
parent
e33013da3f
commit
aaa5cb462e
|
@ -1079,11 +1079,20 @@ export class ChangeLanguageAction extends Action2 {
|
|||
weight: KeybindingWeight.WorkbenchContrib,
|
||||
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyCode.KeyM)
|
||||
},
|
||||
precondition: ContextKeyExpr.not('notebookEditorFocused')
|
||||
precondition: ContextKeyExpr.not('notebookEditorFocused'),
|
||||
metadata: {
|
||||
description: localize('changeLanguageMode.description', "Change the language mode of the active text editor."),
|
||||
args: [
|
||||
{
|
||||
name: localize('changeLanguageMode.arg.name', "The name of the language mode to change to."),
|
||||
constraint: (value: any) => typeof value === 'string',
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
override async run(accessor: ServicesAccessor): Promise<void> {
|
||||
override async run(accessor: ServicesAccessor, languageMode?: string): Promise<void> {
|
||||
const quickInputService = accessor.get(IQuickInputService);
|
||||
const editorService = accessor.get(IEditorService);
|
||||
const languageService = accessor.get(ILanguageService);
|
||||
|
@ -1162,7 +1171,7 @@ export class ChangeLanguageAction extends Action2 {
|
|||
};
|
||||
picks.unshift(autoDetectLanguage);
|
||||
|
||||
const pick = await quickInputService.pick(picks, { placeHolder: localize('pickLanguage', "Select Language Mode"), matchOnDescription: true });
|
||||
const pick = typeof languageMode === 'string' ? { label: languageMode } : await quickInputService.pick(picks, { placeHolder: localize('pickLanguage', "Select Language Mode"), matchOnDescription: true });
|
||||
if (!pick) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue