diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index 01b07f93854cd195e37bd95a3daeeb3d6b6b74eb..76d57ea198f7f5898e9e58703f9af7fe51a112de 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -140,11 +140,12 @@ export function createApiFactory(initData: IInitData, threadService: IThreadServ } } - // namespace: commands - const commands: typeof vscode.commands = { + class Commands { + registerCommand(id: string, command: (...args: any[]) => T | Thenable, thisArgs?: any): vscode.Disposable { return extHostCommands.registerCommand(id, command, thisArgs); - }, + } + registerTextEditorCommand(id: string, callback: (textEditor: vscode.TextEditor, edit: vscode.TextEditorEdit, ...args: any[]) => void, thisArg?: any): vscode.Disposable { return extHostCommands.registerCommand(id, (...args: any[]) => { let activeTextEditor = extHostEditors.getActiveTextEditor(); @@ -165,7 +166,9 @@ export function createApiFactory(initData: IInitData, threadService: IThreadServ console.warn('An error occured while running command ' + id, err); }); }); - }, + } + + @proposed(extension) registerDiffInformationCommand(id: string, callback: (diff: vscode.LineChange[], ...args: any[]) => any, thisArg?: any): vscode.Disposable { return extHostCommands.registerCommand(id, async (...args: any[]) => { let activeTextEditor = extHostEditors.getActiveTextEditor(); @@ -177,14 +180,19 @@ export function createApiFactory(initData: IInitData, threadService: IThreadServ const diff = await extHostEditors.getDiffInformation(activeTextEditor.id); callback.apply(thisArg, [diff, ...args]); }); - }, + } + executeCommand(id: string, ...args: any[]): Thenable { return extHostCommands.executeCommand(id, ...args); - }, + } + getCommands(filterInternal: boolean = false): Thenable { return extHostCommands.getCommands(filterInternal); } - }; + } + + // namespace: commands + const commands: typeof vscode.commands = new Commands(); // namespace: env const env: typeof vscode.env = Object.freeze({