mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
parent
ddd967559b
commit
c059826ba2
|
@ -468,6 +468,11 @@
|
|||
"command": "typescript.organizeImports",
|
||||
"title": "%typescript.organizeImports%",
|
||||
"category": "TypeScript"
|
||||
},
|
||||
{
|
||||
"command": "javascript.organizeImports",
|
||||
"title": "%typescript.organizeImports%",
|
||||
"category": "JavaScript"
|
||||
}
|
||||
],
|
||||
"keybindings": [
|
||||
|
@ -525,7 +530,19 @@
|
|||
},
|
||||
{
|
||||
"command": "typescript.organizeImports",
|
||||
"when": "typescript.isManagedFile && typescript.canOrganizeImports"
|
||||
"when": "editorLangId == typescriptreact && typescript.isManagedFile && typescript.canOrganizeImports"
|
||||
},
|
||||
{
|
||||
"command": "typescript.organizeImports",
|
||||
"when": "editorLangId == typescript && typescript.isManagedFile && typescript.canOrganizeImports"
|
||||
},
|
||||
{
|
||||
"command": "javascript.organizeImports",
|
||||
"when": "editorLangId == javascriptreact && typescript.isManagedFile && typescript.canOrganizeImports"
|
||||
},
|
||||
{
|
||||
"command": "javascript.organizeImports",
|
||||
"when": "editorLangId == javascript && typescript.isManagedFile && typescript.canOrganizeImports"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -15,8 +15,9 @@ import { Lazy } from '../utils/lazy';
|
|||
import TypeScriptServiceClientHost from '../typeScriptServiceClientHost';
|
||||
|
||||
export class OrganizeImportsCommand implements Command {
|
||||
public static readonly ID = 'typescript.organizeImports';
|
||||
public readonly id = OrganizeImportsCommand.ID;
|
||||
public static readonly Ids = ['javascript.organizeImports', 'typescript.organizeImports'];
|
||||
|
||||
public readonly id = OrganizeImportsCommand.Ids;
|
||||
|
||||
constructor(
|
||||
private readonly lazyClientHost: Lazy<TypeScriptServiceClientHost>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
import * as vscode from 'vscode';
|
||||
|
||||
export interface Command {
|
||||
readonly id: string;
|
||||
readonly id: string | string[];
|
||||
|
||||
execute(...args: any[]): void;
|
||||
}
|
||||
|
@ -22,7 +22,9 @@ export class CommandManager {
|
|||
}
|
||||
|
||||
public register<T extends Command>(command: T): T {
|
||||
this.registerCommand(command.id, command.execute, command);
|
||||
for (const id of Array.isArray(command.id) ? command.id : [command.id]) {
|
||||
this.registerCommand(id, command.execute, command);
|
||||
}
|
||||
return command;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue