From 8755a2aa359f0ebf45b66d6b53a4992c77d070e1 Mon Sep 17 00:00:00 2001 From: Harry Hedger Date: Mon, 15 Apr 2019 06:12:54 -0700 Subject: [PATCH 1/7] Implemented onDidExecuteCommand api method --- .../standalone/browser/simpleServices.ts | 5 ++++- .../editor/test/browser/editorTestServices.ts | 5 ++++- .../browser/services/openerService.test.ts | 1 + src/vs/platform/commands/common/commands.ts | 3 +++ .../common/abstractKeybindingService.test.ts | 1 + src/vs/vscode.proposed.d.ts | 8 ++++++++ .../api/browser/mainThreadCommands.ts | 10 +++++++++- .../workbench/api/common/extHost.protocol.ts | 4 +++- .../workbench/api/common/extHostCommands.ts | 19 +++++++++++++++++-- src/vs/workbench/api/node/extHost.api.impl.ts | 5 ++++- .../commands/common/commandService.ts | 9 ++++++++- .../configurationResolverService.test.ts | 1 + .../api/extHostMessagerService.test.ts | 1 + 13 files changed, 64 insertions(+), 8 deletions(-) diff --git a/src/vs/editor/standalone/browser/simpleServices.ts b/src/vs/editor/standalone/browser/simpleServices.ts index b6468cddfc1..6d16f975897 100644 --- a/src/vs/editor/standalone/browser/simpleServices.ts +++ b/src/vs/editor/standalone/browser/simpleServices.ts @@ -225,7 +225,9 @@ export class StandaloneCommandService implements ICommandService { private readonly _dynamicCommands: { [id: string]: ICommand; }; private readonly _onWillExecuteCommand = new Emitter(); + private readonly _onDidExecuteCommand = new Emitter(); public readonly onWillExecuteCommand: Event = this._onWillExecuteCommand.event; + public readonly onDidExecuteCommand: Event = this._onDidExecuteCommand.event; constructor(instantiationService: IInstantiationService) { this._instantiationService = instantiationService; @@ -247,8 +249,9 @@ export class StandaloneCommandService implements ICommandService { } try { - this._onWillExecuteCommand.fire({ commandId: id }); + this._onWillExecuteCommand.fire({ commandId: id, args }); const result = this._instantiationService.invokeFunction.apply(this._instantiationService, [command.handler, ...args]) as T; + this._onDidExecuteCommand.fire({ commandId: id, args }); return Promise.resolve(result); } catch (err) { return Promise.reject(err); diff --git a/src/vs/editor/test/browser/editorTestServices.ts b/src/vs/editor/test/browser/editorTestServices.ts index 25af3b0efa6..fc005b742a9 100644 --- a/src/vs/editor/test/browser/editorTestServices.ts +++ b/src/vs/editor/test/browser/editorTestServices.ts @@ -32,6 +32,9 @@ export class TestCommandService implements ICommandService { private readonly _onWillExecuteCommand = new Emitter(); public readonly onWillExecuteCommand: Event = this._onWillExecuteCommand.event; + private readonly _onDidExecuteCommand = new Emitter(); + public readonly onDidExecuteCommand: Event = this._onDidExecuteCommand.event; + constructor(instantiationService: IInstantiationService) { this._instantiationService = instantiationService; } @@ -43,7 +46,7 @@ export class TestCommandService implements ICommandService { } try { - this._onWillExecuteCommand.fire({ commandId: id }); + this._onWillExecuteCommand.fire({ commandId: id, args }); const result = this._instantiationService.invokeFunction.apply(this._instantiationService, [command.handler, ...args]) as T; return Promise.resolve(result); } catch (err) { diff --git a/src/vs/editor/test/browser/services/openerService.test.ts b/src/vs/editor/test/browser/services/openerService.test.ts index 3e643742469..eadf902357a 100644 --- a/src/vs/editor/test/browser/services/openerService.test.ts +++ b/src/vs/editor/test/browser/services/openerService.test.ts @@ -17,6 +17,7 @@ suite('OpenerService', function () { const commandService = new class implements ICommandService { _serviceBrand: any; onWillExecuteCommand = () => ({ dispose: () => { } }); + onDidExecuteCommand = () => ({ dispose: () => { } }); executeCommand(id: string, ...args: any[]): Promise { lastCommand = { id, args }; return Promise.resolve(undefined); diff --git a/src/vs/platform/commands/common/commands.ts b/src/vs/platform/commands/common/commands.ts index 91541847a17..bb15b457bc8 100644 --- a/src/vs/platform/commands/common/commands.ts +++ b/src/vs/platform/commands/common/commands.ts @@ -14,11 +14,13 @@ export const ICommandService = createDecorator('commandService' export interface ICommandEvent { commandId: string; + args: any[]; } export interface ICommandService { _serviceBrand: any; onWillExecuteCommand: Event; + onDidExecuteCommand: Event; executeCommand(commandId: string, ...args: any[]): Promise; } @@ -133,6 +135,7 @@ export const CommandsRegistry: ICommandRegistry = new class implements ICommandR export const NullCommandService: ICommandService = { _serviceBrand: undefined, onWillExecuteCommand: () => ({ dispose: () => { } }), + onDidExecuteCommand: () => ({ dispose: () => { } }), executeCommand() { return Promise.resolve(undefined); } diff --git a/src/vs/platform/keybinding/test/common/abstractKeybindingService.test.ts b/src/vs/platform/keybinding/test/common/abstractKeybindingService.test.ts index d2b97151250..055362596c5 100644 --- a/src/vs/platform/keybinding/test/common/abstractKeybindingService.test.ts +++ b/src/vs/platform/keybinding/test/common/abstractKeybindingService.test.ts @@ -119,6 +119,7 @@ suite('AbstractKeybindingService', () => { let commandService: ICommandService = { _serviceBrand: undefined, onWillExecuteCommand: () => ({ dispose: () => { } }), + onDidExecuteCommand: () => ({ dispose: () => { } }), executeCommand: (commandId: string, ...args: any[]): Promise => { executeCommandCalls.push({ commandId: commandId, diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index b1c6b84bb3b..ffbbb08e063 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -1,3 +1,5 @@ +import { ICommandEvent } from 'vs/platform/commands/common/commands' + /*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. @@ -555,6 +557,12 @@ declare module 'vscode' { * @return Disposable which unregisters this command on disposal. */ export function registerDiffInformationCommand(command: string, callback: (diff: LineChange[], ...args: any[]) => any, thisArg?: any): Disposable; + + + /** + * An event that is emitted when a [command](#Command) is executed. + */ + export const onDidExecuteCommand: Event; } //#endregion diff --git a/src/vs/workbench/api/browser/mainThreadCommands.ts b/src/vs/workbench/api/browser/mainThreadCommands.ts index c61ad7e5733..6d0e3c9276c 100644 --- a/src/vs/workbench/api/browser/mainThreadCommands.ts +++ b/src/vs/workbench/api/browser/mainThreadCommands.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { ICommandService, CommandsRegistry, ICommandHandlerDescription } from 'vs/platform/commands/common/commands'; +import { ICommandService, CommandsRegistry, ICommandHandlerDescription, ICommandEvent } from 'vs/platform/commands/common/commands'; import { IDisposable } from 'vs/base/common/lifecycle'; import { ExtHostContext, MainThreadCommandsShape, ExtHostCommandsShape, MainContext, IExtHostContext } from '../common/extHost.protocol'; import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers'; @@ -78,9 +78,17 @@ export class MainThreadCommands implements MainThreadCommandsShape { return this._commandService.executeCommand(id, ...args); } + $onDidExecuteCommand() { + return this._commandService.onDidExecuteCommand((command) => this.handleExecuteCommand(command)); + } + $getCommands(): Promise { return Promise.resolve(Object.keys(CommandsRegistry.getCommands())); } + + handleExecuteCommand(command: ICommandEvent) { + this._proxy.$handleDidExecuteCommand(command); + } } // --- command doc diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts index cff14ddb273..8e836e5de1a 100644 --- a/src/vs/workbench/api/common/extHost.protocol.ts +++ b/src/vs/workbench/api/common/extHost.protocol.ts @@ -17,7 +17,7 @@ import { ISingleEditOperation, EndOfLineSequence } from 'vs/editor/common/model' import { IModelChangedEvent } from 'vs/editor/common/model/mirrorTextModel'; import * as modes from 'vs/editor/common/modes'; import { CharacterPair, CommentRule, EnterAction } from 'vs/editor/common/modes/languageConfiguration'; -import { ICommandHandlerDescription } from 'vs/platform/commands/common/commands'; +import { ICommandHandlerDescription, ICommandEvent } from 'vs/platform/commands/common/commands'; import { ConfigurationTarget, IConfigurationData, IConfigurationModel } from 'vs/platform/configuration/common/configuration'; import { ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry'; import * as files from 'vs/platform/files/common/files'; @@ -113,6 +113,7 @@ export interface MainThreadClipboardShape extends IDisposable { export interface MainThreadCommandsShape extends IDisposable { $registerCommand(id: string): void; + $onDidExecuteCommand(): void; $unregisterCommand(id: string): void; $executeCommand(id: string, args: any[]): Promise; $getCommands(): Promise; @@ -709,6 +710,7 @@ export interface MainThreadWindowShape extends IDisposable { export interface ExtHostCommandsShape { $executeContributedCommand(id: string, ...args: any[]): Promise; $getContributedCommandHandlerDescriptions(): Promise<{ [id: string]: string | ICommandHandlerDescription }>; + $handleDidExecuteCommand(command: ICommandEvent): void; } export interface ExtHostConfigurationShape { diff --git a/src/vs/workbench/api/common/extHostCommands.ts b/src/vs/workbench/api/common/extHostCommands.ts index 59edc45abf3..449e15e600b 100644 --- a/src/vs/workbench/api/common/extHostCommands.ts +++ b/src/vs/workbench/api/common/extHostCommands.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { validateConstraint } from 'vs/base/common/types'; -import { ICommandHandlerDescription } from 'vs/platform/commands/common/commands'; +import { ICommandHandlerDescription, ICommandEvent } from 'vs/platform/commands/common/commands'; import * as extHostTypes from 'vs/workbench/api/common/extHostTypes'; import * as extHostTypeConverter from 'vs/workbench/api/common/extHostTypeConverters'; import { cloneAndChange } from 'vs/base/common/objects'; @@ -18,6 +18,8 @@ import { revive } from 'vs/base/common/marshalling'; import { Range } from 'vs/editor/common/core/range'; import { Position } from 'vs/editor/common/core/position'; import { URI } from 'vs/base/common/uri'; +import { Event, Emitter } from 'vs/base/common/event'; +import { IDisposable } from 'vs/base/common/lifecycle'; interface CommandHandler { callback: Function; @@ -30,6 +32,8 @@ export interface ArgumentProcessor { } export class ExtHostCommands implements ExtHostCommandsShape { + private readonly _onDidExecuteCommand: Emitter = new Emitter(); + public readonly onDidExecuteCommandEmitter: Event = this._onDidExecuteCommand.event; private readonly _commands = new Map(); private readonly _proxy: MainThreadCommandsShape; @@ -107,6 +111,15 @@ export class ExtHostCommands implements ExtHostCommandsShape { }); } + onDidExecuteCommand(listener: (command: ICommandEvent) => any, thisArgs?: any, disposables?: IDisposable[]) { + this._proxy.$onDidExecuteCommand(); + return this.onDidExecuteCommandEmitter(listener, thisArgs, disposables); + } + + $handleDidExecuteCommand(command: ICommandEvent): void { + this._onDidExecuteCommand.fire(command); + } + executeCommand(id: string, ...args: any[]): Promise { this._logService.trace('ExtHostCommands#executeCommand', id); @@ -133,7 +146,9 @@ export class ExtHostCommands implements ExtHostCommandsShape { } }); - return this._proxy.$executeCommand(id, args).then(result => revive(result, 0)); + return this._proxy.$executeCommand(id, args).then(result => { + return revive(result, 0); + }); } } diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index ffe929454e3..0e527dab21a 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -230,7 +230,10 @@ export function createApiFactory( }, getCommands(filterInternal: boolean = false): Thenable { return extHostCommands.getCommands(filterInternal); - } + }, + onDidExecuteCommand: (listener, thisArgs?, disposables?) => { + return extHostCommands.onDidExecuteCommand(listener, thisArgs, disposables); + }, }; // namespace: env diff --git a/src/vs/workbench/services/commands/common/commandService.ts b/src/vs/workbench/services/commands/common/commandService.ts index ffb7d1ebd83..c396d7ed897 100644 --- a/src/vs/workbench/services/commands/common/commandService.ts +++ b/src/vs/workbench/services/commands/common/commandService.ts @@ -22,6 +22,9 @@ export class CommandService extends Disposable implements ICommandService { private readonly _onWillExecuteCommand: Emitter = this._register(new Emitter()); public readonly onWillExecuteCommand: Event = this._onWillExecuteCommand.event; + private readonly _onDidExecuteCommand: Emitter = new Emitter(); + public readonly onDidExecuteCommand: Event = this._onDidExecuteCommand.event; + constructor( @IInstantiationService private readonly _instantiationService: IInstantiationService, @IExtensionService private readonly _extensionService: IExtensionService, @@ -77,8 +80,12 @@ export class CommandService extends Disposable implements ICommandService { return Promise.reject(new Error(`command '${id}' not found`)); } try { - this._onWillExecuteCommand.fire({ commandId: id }); + this._onWillExecuteCommand.fire({ commandId: id, args }); const result = this._instantiationService.invokeFunction.apply(this._instantiationService, [command.handler, ...args]); + this._onDidExecuteCommand.fire({ + commandId: id, + args, + }); return Promise.resolve(result); } catch (err) { return Promise.reject(err); diff --git a/src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts b/src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts index cefee9701c9..5b9f44514e9 100644 --- a/src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts +++ b/src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts @@ -523,6 +523,7 @@ class MockCommandService implements ICommandService { public callCount = 0; onWillExecuteCommand = () => Disposable.None; + onDidExecuteCommand = () => Disposable.None; public executeCommand(commandId: string, ...args: any[]): Promise { this.callCount++; diff --git a/src/vs/workbench/test/electron-browser/api/extHostMessagerService.test.ts b/src/vs/workbench/test/electron-browser/api/extHostMessagerService.test.ts index 9ffa9aee794..c19beb1371f 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostMessagerService.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostMessagerService.test.ts @@ -24,6 +24,7 @@ const emptyDialogService = new class implements IDialogService { const emptyCommandService: ICommandService = { _serviceBrand: undefined, onWillExecuteCommand: () => ({ dispose: () => { } }), + onDidExecuteCommand: () => ({ dispose: () => { } }), executeCommand: (commandId: string, ...args: any[]): Promise => { return Promise.resolve(undefined); } From b9c3c20a75bd1de02f2e139e3c20d4352bd2cd82 Mon Sep 17 00:00:00 2001 From: Harry Hedger Date: Tue, 16 Apr 2019 01:51:22 -0700 Subject: [PATCH 2/7] Made recommended changes --- .../editor/standalone/browser/simpleServices.ts | 2 ++ src/vs/editor/test/browser/editorTestServices.ts | 2 ++ .../test/browser/services/openerService.test.ts | 1 + src/vs/platform/commands/common/commands.ts | 2 ++ .../test/common/abstractKeybindingService.test.ts | 1 + src/vs/vscode.proposed.d.ts | 6 ++++-- .../workbench/api/browser/mainThreadCommands.ts | 4 ++++ src/vs/workbench/api/common/extHost.protocol.ts | 1 + src/vs/workbench/api/common/extHostCommands.ts | 15 +++++++++------ src/vs/workbench/api/node/extHost.api.impl.ts | 4 ++-- .../services/commands/common/commandService.ts | 6 ++---- .../configurationResolverService.test.ts | 1 + .../api/extHostMessagerService.test.ts | 1 + 13 files changed, 32 insertions(+), 14 deletions(-) diff --git a/src/vs/editor/standalone/browser/simpleServices.ts b/src/vs/editor/standalone/browser/simpleServices.ts index 6d16f975897..53480932df3 100644 --- a/src/vs/editor/standalone/browser/simpleServices.ts +++ b/src/vs/editor/standalone/browser/simpleServices.ts @@ -228,6 +228,7 @@ export class StandaloneCommandService implements ICommandService { private readonly _onDidExecuteCommand = new Emitter(); public readonly onWillExecuteCommand: Event = this._onWillExecuteCommand.event; public readonly onDidExecuteCommand: Event = this._onDidExecuteCommand.event; + public readonly disposeListeners: () => void; constructor(instantiationService: IInstantiationService) { this._instantiationService = instantiationService; @@ -251,6 +252,7 @@ export class StandaloneCommandService implements ICommandService { try { this._onWillExecuteCommand.fire({ commandId: id, args }); const result = this._instantiationService.invokeFunction.apply(this._instantiationService, [command.handler, ...args]) as T; + this._onDidExecuteCommand.fire({ commandId: id, args }); return Promise.resolve(result); } catch (err) { diff --git a/src/vs/editor/test/browser/editorTestServices.ts b/src/vs/editor/test/browser/editorTestServices.ts index fc005b742a9..f3cca955cd5 100644 --- a/src/vs/editor/test/browser/editorTestServices.ts +++ b/src/vs/editor/test/browser/editorTestServices.ts @@ -35,6 +35,8 @@ export class TestCommandService implements ICommandService { private readonly _onDidExecuteCommand = new Emitter(); public readonly onDidExecuteCommand: Event = this._onDidExecuteCommand.event; + public readonly disposeListeners: () => void; + constructor(instantiationService: IInstantiationService) { this._instantiationService = instantiationService; } diff --git a/src/vs/editor/test/browser/services/openerService.test.ts b/src/vs/editor/test/browser/services/openerService.test.ts index eadf902357a..e42545251ea 100644 --- a/src/vs/editor/test/browser/services/openerService.test.ts +++ b/src/vs/editor/test/browser/services/openerService.test.ts @@ -18,6 +18,7 @@ suite('OpenerService', function () { _serviceBrand: any; onWillExecuteCommand = () => ({ dispose: () => { } }); onDidExecuteCommand = () => ({ dispose: () => { } }); + disposeListeners = () => { }; executeCommand(id: string, ...args: any[]): Promise { lastCommand = { id, args }; return Promise.resolve(undefined); diff --git a/src/vs/platform/commands/common/commands.ts b/src/vs/platform/commands/common/commands.ts index bb15b457bc8..d7d70fe07d7 100644 --- a/src/vs/platform/commands/common/commands.ts +++ b/src/vs/platform/commands/common/commands.ts @@ -21,6 +21,7 @@ export interface ICommandService { _serviceBrand: any; onWillExecuteCommand: Event; onDidExecuteCommand: Event; + disposeListeners: () => void; executeCommand(commandId: string, ...args: any[]): Promise; } @@ -136,6 +137,7 @@ export const NullCommandService: ICommandService = { _serviceBrand: undefined, onWillExecuteCommand: () => ({ dispose: () => { } }), onDidExecuteCommand: () => ({ dispose: () => { } }), + disposeListeners: () => { }, executeCommand() { return Promise.resolve(undefined); } diff --git a/src/vs/platform/keybinding/test/common/abstractKeybindingService.test.ts b/src/vs/platform/keybinding/test/common/abstractKeybindingService.test.ts index 055362596c5..8c9a8cccbdb 100644 --- a/src/vs/platform/keybinding/test/common/abstractKeybindingService.test.ts +++ b/src/vs/platform/keybinding/test/common/abstractKeybindingService.test.ts @@ -120,6 +120,7 @@ suite('AbstractKeybindingService', () => { _serviceBrand: undefined, onWillExecuteCommand: () => ({ dispose: () => { } }), onDidExecuteCommand: () => ({ dispose: () => { } }), + disposeListeners: () => { }, executeCommand: (commandId: string, ...args: any[]): Promise => { executeCommandCalls.push({ commandId: commandId, diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index ffbbb08e063..370c8524198 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -1,5 +1,3 @@ -import { ICommandEvent } from 'vs/platform/commands/common/commands' - /*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. @@ -558,6 +556,10 @@ declare module 'vscode' { */ export function registerDiffInformationCommand(command: string, callback: (diff: LineChange[], ...args: any[]) => any, thisArg?: any): Disposable; + export interface ICommandEvent { + commandId: string; + args: any[]; + } /** * An event that is emitted when a [command](#Command) is executed. diff --git a/src/vs/workbench/api/browser/mainThreadCommands.ts b/src/vs/workbench/api/browser/mainThreadCommands.ts index 6d0e3c9276c..008e3729037 100644 --- a/src/vs/workbench/api/browser/mainThreadCommands.ts +++ b/src/vs/workbench/api/browser/mainThreadCommands.ts @@ -82,6 +82,10 @@ export class MainThreadCommands implements MainThreadCommandsShape { return this._commandService.onDidExecuteCommand((command) => this.handleExecuteCommand(command)); } + $disposeListeners() { + return this._commandService.disposeListeners(); + } + $getCommands(): Promise { return Promise.resolve(Object.keys(CommandsRegistry.getCommands())); } diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts index 8e836e5de1a..c0f52cded80 100644 --- a/src/vs/workbench/api/common/extHost.protocol.ts +++ b/src/vs/workbench/api/common/extHost.protocol.ts @@ -114,6 +114,7 @@ export interface MainThreadClipboardShape extends IDisposable { export interface MainThreadCommandsShape extends IDisposable { $registerCommand(id: string): void; $onDidExecuteCommand(): void; + $disposeListeners(): void; $unregisterCommand(id: string): void; $executeCommand(id: string, args: any[]): Promise; $getCommands(): Promise; diff --git a/src/vs/workbench/api/common/extHostCommands.ts b/src/vs/workbench/api/common/extHostCommands.ts index 449e15e600b..84042c6529b 100644 --- a/src/vs/workbench/api/common/extHostCommands.ts +++ b/src/vs/workbench/api/common/extHostCommands.ts @@ -32,8 +32,8 @@ export interface ArgumentProcessor { } export class ExtHostCommands implements ExtHostCommandsShape { - private readonly _onDidExecuteCommand: Emitter = new Emitter(); - public readonly onDidExecuteCommandEmitter: Event = this._onDidExecuteCommand.event; + private readonly _onDidExecuteCommand: Emitter; + public readonly onDidExecuteCommandEmitter: Event; private readonly _commands = new Map(); private readonly _proxy: MainThreadCommandsShape; @@ -47,6 +47,11 @@ export class ExtHostCommands implements ExtHostCommandsShape { logService: ILogService ) { this._proxy = mainContext.getProxy(MainContext.MainThreadCommands); + this._onDidExecuteCommand = new Emitter({ + onFirstListenerDidAdd: this._proxy.$onDidExecuteCommand, + onLastListenerRemove: this._proxy.$disposeListeners, + }); + this.onDidExecuteCommandEmitter = this._onDidExecuteCommand.event; this._logService = logService; this._converter = new CommandsConverter(this, heapService); this._argumentProcessors = [ @@ -112,7 +117,6 @@ export class ExtHostCommands implements ExtHostCommandsShape { } onDidExecuteCommand(listener: (command: ICommandEvent) => any, thisArgs?: any, disposables?: IDisposable[]) { - this._proxy.$onDidExecuteCommand(); return this.onDidExecuteCommandEmitter(listener, thisArgs, disposables); } @@ -146,9 +150,7 @@ export class ExtHostCommands implements ExtHostCommandsShape { } }); - return this._proxy.$executeCommand(id, args).then(result => { - return revive(result, 0); - }); + return this._proxy.$executeCommand(id, args).then(result => revive(result, 0)); } } @@ -170,6 +172,7 @@ export class ExtHostCommands implements ExtHostCommandsShape { try { const result = callback.apply(thisArg, args); + this._onDidExecuteCommand.fire({ commandId: id, args }); return Promise.resolve(result); } catch (err) { this._logService.error(err, id); diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index 0e527dab21a..4013345e06a 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -231,9 +231,9 @@ export function createApiFactory( getCommands(filterInternal: boolean = false): Thenable { return extHostCommands.getCommands(filterInternal); }, - onDidExecuteCommand: (listener, thisArgs?, disposables?) => { + onDidExecuteCommand: proposedApiFunction(extension, (listener, thisArgs?, disposables?) => { return extHostCommands.onDidExecuteCommand(listener, thisArgs, disposables); - }, + }), }; // namespace: env diff --git a/src/vs/workbench/services/commands/common/commandService.ts b/src/vs/workbench/services/commands/common/commandService.ts index c396d7ed897..07e4f8d25ea 100644 --- a/src/vs/workbench/services/commands/common/commandService.ts +++ b/src/vs/workbench/services/commands/common/commandService.ts @@ -24,6 +24,7 @@ export class CommandService extends Disposable implements ICommandService { private readonly _onDidExecuteCommand: Emitter = new Emitter(); public readonly onDidExecuteCommand: Event = this._onDidExecuteCommand.event; + public readonly disposeListeners: () => void = () => this._onDidExecuteCommand.dispose(); constructor( @IInstantiationService private readonly _instantiationService: IInstantiationService, @@ -82,10 +83,7 @@ export class CommandService extends Disposable implements ICommandService { try { this._onWillExecuteCommand.fire({ commandId: id, args }); const result = this._instantiationService.invokeFunction.apply(this._instantiationService, [command.handler, ...args]); - this._onDidExecuteCommand.fire({ - commandId: id, - args, - }); + this._onDidExecuteCommand.fire({ commandId: id, args }); return Promise.resolve(result); } catch (err) { return Promise.reject(err); diff --git a/src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts b/src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts index 5b9f44514e9..dab2143fe05 100644 --- a/src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts +++ b/src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts @@ -524,6 +524,7 @@ class MockCommandService implements ICommandService { onWillExecuteCommand = () => Disposable.None; onDidExecuteCommand = () => Disposable.None; + disposeListeners = () => { }; public executeCommand(commandId: string, ...args: any[]): Promise { this.callCount++; diff --git a/src/vs/workbench/test/electron-browser/api/extHostMessagerService.test.ts b/src/vs/workbench/test/electron-browser/api/extHostMessagerService.test.ts index c19beb1371f..d4918ec62c2 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostMessagerService.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostMessagerService.test.ts @@ -25,6 +25,7 @@ const emptyCommandService: ICommandService = { _serviceBrand: undefined, onWillExecuteCommand: () => ({ dispose: () => { } }), onDidExecuteCommand: () => ({ dispose: () => { } }), + disposeListeners: () => { }, executeCommand: (commandId: string, ...args: any[]): Promise => { return Promise.resolve(undefined); } From 43e0b18c5bb35a84a38abd98d218d5e1e82d0218 Mon Sep 17 00:00:00 2001 From: Harry Hedger Date: Tue, 16 Apr 2019 02:25:51 -0700 Subject: [PATCH 3/7] removed public --- src/vs/workbench/api/common/extHostCommands.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/api/common/extHostCommands.ts b/src/vs/workbench/api/common/extHostCommands.ts index 84042c6529b..53f4d85d636 100644 --- a/src/vs/workbench/api/common/extHostCommands.ts +++ b/src/vs/workbench/api/common/extHostCommands.ts @@ -33,7 +33,7 @@ export interface ArgumentProcessor { export class ExtHostCommands implements ExtHostCommandsShape { private readonly _onDidExecuteCommand: Emitter; - public readonly onDidExecuteCommandEmitter: Event; + readonly onDidExecuteCommandEmitter: Event; private readonly _commands = new Map(); private readonly _proxy: MainThreadCommandsShape; From 62f2b712f012c1f42ca5e02222109d4aa7b58050 Mon Sep 17 00:00:00 2001 From: Harry Hedger Date: Tue, 30 Apr 2019 03:04:16 -0700 Subject: [PATCH 4/7] Removed disposeListeners from commandService and only remove listener on MainThreadCommands --- src/vs/editor/standalone/browser/simpleServices.ts | 1 - src/vs/editor/test/browser/editorTestServices.ts | 3 +-- src/vs/editor/test/browser/services/openerService.test.ts | 1 - src/vs/platform/commands/common/commands.ts | 2 -- .../test/common/abstractKeybindingService.test.ts | 1 - src/vs/workbench/api/browser/mainThreadCommands.ts | 7 ++++--- src/vs/workbench/api/common/extHost.protocol.ts | 2 +- src/vs/workbench/api/common/extHostCommands.ts | 2 +- .../workbench/services/commands/common/commandService.ts | 1 - .../electron-browser/configurationResolverService.test.ts | 1 - .../electron-browser/api/extHostMessagerService.test.ts | 1 - 11 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/vs/editor/standalone/browser/simpleServices.ts b/src/vs/editor/standalone/browser/simpleServices.ts index 53480932df3..2c354a407c5 100644 --- a/src/vs/editor/standalone/browser/simpleServices.ts +++ b/src/vs/editor/standalone/browser/simpleServices.ts @@ -228,7 +228,6 @@ export class StandaloneCommandService implements ICommandService { private readonly _onDidExecuteCommand = new Emitter(); public readonly onWillExecuteCommand: Event = this._onWillExecuteCommand.event; public readonly onDidExecuteCommand: Event = this._onDidExecuteCommand.event; - public readonly disposeListeners: () => void; constructor(instantiationService: IInstantiationService) { this._instantiationService = instantiationService; diff --git a/src/vs/editor/test/browser/editorTestServices.ts b/src/vs/editor/test/browser/editorTestServices.ts index f3cca955cd5..f896360acf4 100644 --- a/src/vs/editor/test/browser/editorTestServices.ts +++ b/src/vs/editor/test/browser/editorTestServices.ts @@ -35,8 +35,6 @@ export class TestCommandService implements ICommandService { private readonly _onDidExecuteCommand = new Emitter(); public readonly onDidExecuteCommand: Event = this._onDidExecuteCommand.event; - public readonly disposeListeners: () => void; - constructor(instantiationService: IInstantiationService) { this._instantiationService = instantiationService; } @@ -50,6 +48,7 @@ export class TestCommandService implements ICommandService { try { this._onWillExecuteCommand.fire({ commandId: id, args }); const result = this._instantiationService.invokeFunction.apply(this._instantiationService, [command.handler, ...args]) as T; + this._onDidExecuteCommand.fire({ commandId: id, args }); return Promise.resolve(result); } catch (err) { return Promise.reject(err); diff --git a/src/vs/editor/test/browser/services/openerService.test.ts b/src/vs/editor/test/browser/services/openerService.test.ts index e42545251ea..eadf902357a 100644 --- a/src/vs/editor/test/browser/services/openerService.test.ts +++ b/src/vs/editor/test/browser/services/openerService.test.ts @@ -18,7 +18,6 @@ suite('OpenerService', function () { _serviceBrand: any; onWillExecuteCommand = () => ({ dispose: () => { } }); onDidExecuteCommand = () => ({ dispose: () => { } }); - disposeListeners = () => { }; executeCommand(id: string, ...args: any[]): Promise { lastCommand = { id, args }; return Promise.resolve(undefined); diff --git a/src/vs/platform/commands/common/commands.ts b/src/vs/platform/commands/common/commands.ts index d7d70fe07d7..bb15b457bc8 100644 --- a/src/vs/platform/commands/common/commands.ts +++ b/src/vs/platform/commands/common/commands.ts @@ -21,7 +21,6 @@ export interface ICommandService { _serviceBrand: any; onWillExecuteCommand: Event; onDidExecuteCommand: Event; - disposeListeners: () => void; executeCommand(commandId: string, ...args: any[]): Promise; } @@ -137,7 +136,6 @@ export const NullCommandService: ICommandService = { _serviceBrand: undefined, onWillExecuteCommand: () => ({ dispose: () => { } }), onDidExecuteCommand: () => ({ dispose: () => { } }), - disposeListeners: () => { }, executeCommand() { return Promise.resolve(undefined); } diff --git a/src/vs/platform/keybinding/test/common/abstractKeybindingService.test.ts b/src/vs/platform/keybinding/test/common/abstractKeybindingService.test.ts index 8c9a8cccbdb..055362596c5 100644 --- a/src/vs/platform/keybinding/test/common/abstractKeybindingService.test.ts +++ b/src/vs/platform/keybinding/test/common/abstractKeybindingService.test.ts @@ -120,7 +120,6 @@ suite('AbstractKeybindingService', () => { _serviceBrand: undefined, onWillExecuteCommand: () => ({ dispose: () => { } }), onDidExecuteCommand: () => ({ dispose: () => { } }), - disposeListeners: () => { }, executeCommand: (commandId: string, ...args: any[]): Promise => { executeCommandCalls.push({ commandId: commandId, diff --git a/src/vs/workbench/api/browser/mainThreadCommands.ts b/src/vs/workbench/api/browser/mainThreadCommands.ts index 008e3729037..3f98aed5553 100644 --- a/src/vs/workbench/api/browser/mainThreadCommands.ts +++ b/src/vs/workbench/api/browser/mainThreadCommands.ts @@ -15,6 +15,7 @@ export class MainThreadCommands implements MainThreadCommandsShape { private readonly _disposables = new Map(); private readonly _generateCommandsDocumentationRegistration: IDisposable; private readonly _proxy: ExtHostCommandsShape; + private _onDidExecuteCommandListener: IDisposable; constructor( extHostContext: IExtHostContext, @@ -79,11 +80,11 @@ export class MainThreadCommands implements MainThreadCommandsShape { } $onDidExecuteCommand() { - return this._commandService.onDidExecuteCommand((command) => this.handleExecuteCommand(command)); + this._onDidExecuteCommandListener = this._commandService.onDidExecuteCommand((command) => this.handleExecuteCommand(command)); } - $disposeListeners() { - return this._commandService.disposeListeners(); + $disposeListener() { + return this._onDidExecuteCommandListener.dispose(); } $getCommands(): Promise { diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts index c0f52cded80..71446f49d62 100644 --- a/src/vs/workbench/api/common/extHost.protocol.ts +++ b/src/vs/workbench/api/common/extHost.protocol.ts @@ -114,7 +114,7 @@ export interface MainThreadClipboardShape extends IDisposable { export interface MainThreadCommandsShape extends IDisposable { $registerCommand(id: string): void; $onDidExecuteCommand(): void; - $disposeListeners(): void; + $disposeListener(): void; $unregisterCommand(id: string): void; $executeCommand(id: string, args: any[]): Promise; $getCommands(): Promise; diff --git a/src/vs/workbench/api/common/extHostCommands.ts b/src/vs/workbench/api/common/extHostCommands.ts index 53f4d85d636..bdd6219fda2 100644 --- a/src/vs/workbench/api/common/extHostCommands.ts +++ b/src/vs/workbench/api/common/extHostCommands.ts @@ -49,7 +49,7 @@ export class ExtHostCommands implements ExtHostCommandsShape { this._proxy = mainContext.getProxy(MainContext.MainThreadCommands); this._onDidExecuteCommand = new Emitter({ onFirstListenerDidAdd: this._proxy.$onDidExecuteCommand, - onLastListenerRemove: this._proxy.$disposeListeners, + onLastListenerRemove: this._proxy.$disposeListener, }); this.onDidExecuteCommandEmitter = this._onDidExecuteCommand.event; this._logService = logService; diff --git a/src/vs/workbench/services/commands/common/commandService.ts b/src/vs/workbench/services/commands/common/commandService.ts index 07e4f8d25ea..f1826cd036a 100644 --- a/src/vs/workbench/services/commands/common/commandService.ts +++ b/src/vs/workbench/services/commands/common/commandService.ts @@ -24,7 +24,6 @@ export class CommandService extends Disposable implements ICommandService { private readonly _onDidExecuteCommand: Emitter = new Emitter(); public readonly onDidExecuteCommand: Event = this._onDidExecuteCommand.event; - public readonly disposeListeners: () => void = () => this._onDidExecuteCommand.dispose(); constructor( @IInstantiationService private readonly _instantiationService: IInstantiationService, diff --git a/src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts b/src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts index dab2143fe05..5b9f44514e9 100644 --- a/src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts +++ b/src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts @@ -524,7 +524,6 @@ class MockCommandService implements ICommandService { onWillExecuteCommand = () => Disposable.None; onDidExecuteCommand = () => Disposable.None; - disposeListeners = () => { }; public executeCommand(commandId: string, ...args: any[]): Promise { this.callCount++; diff --git a/src/vs/workbench/test/electron-browser/api/extHostMessagerService.test.ts b/src/vs/workbench/test/electron-browser/api/extHostMessagerService.test.ts index d4918ec62c2..c19beb1371f 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostMessagerService.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostMessagerService.test.ts @@ -25,7 +25,6 @@ const emptyCommandService: ICommandService = { _serviceBrand: undefined, onWillExecuteCommand: () => ({ dispose: () => { } }), onDidExecuteCommand: () => ({ dispose: () => { } }), - disposeListeners: () => { }, executeCommand: (commandId: string, ...args: any[]): Promise => { return Promise.resolve(undefined); } From ab7694754b6b2b6b39e66ef8890d0c7ffcb8a7c3 Mon Sep 17 00:00:00 2001 From: Harry Hedger Date: Tue, 30 Apr 2019 05:57:47 -0700 Subject: [PATCH 5/7] renamed listeners to registerCommandListener and unregisterCommandListener --- src/vs/workbench/api/browser/mainThreadCommands.ts | 4 ++-- src/vs/workbench/api/common/extHost.protocol.ts | 4 ++-- src/vs/workbench/api/common/extHostCommands.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/vs/workbench/api/browser/mainThreadCommands.ts b/src/vs/workbench/api/browser/mainThreadCommands.ts index 3f98aed5553..1f63ed47dd0 100644 --- a/src/vs/workbench/api/browser/mainThreadCommands.ts +++ b/src/vs/workbench/api/browser/mainThreadCommands.ts @@ -79,11 +79,11 @@ export class MainThreadCommands implements MainThreadCommandsShape { return this._commandService.executeCommand(id, ...args); } - $onDidExecuteCommand() { + $registerCommandListener() { this._onDidExecuteCommandListener = this._commandService.onDidExecuteCommand((command) => this.handleExecuteCommand(command)); } - $disposeListener() { + $unregisterCommandListener() { return this._onDidExecuteCommandListener.dispose(); } diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts index 71446f49d62..7dafdda0c68 100644 --- a/src/vs/workbench/api/common/extHost.protocol.ts +++ b/src/vs/workbench/api/common/extHost.protocol.ts @@ -113,8 +113,8 @@ export interface MainThreadClipboardShape extends IDisposable { export interface MainThreadCommandsShape extends IDisposable { $registerCommand(id: string): void; - $onDidExecuteCommand(): void; - $disposeListener(): void; + $registerCommandListener(): void; + $unregisterCommandListener(): void; $unregisterCommand(id: string): void; $executeCommand(id: string, args: any[]): Promise; $getCommands(): Promise; diff --git a/src/vs/workbench/api/common/extHostCommands.ts b/src/vs/workbench/api/common/extHostCommands.ts index bdd6219fda2..2c84c8d03f7 100644 --- a/src/vs/workbench/api/common/extHostCommands.ts +++ b/src/vs/workbench/api/common/extHostCommands.ts @@ -48,8 +48,8 @@ export class ExtHostCommands implements ExtHostCommandsShape { ) { this._proxy = mainContext.getProxy(MainContext.MainThreadCommands); this._onDidExecuteCommand = new Emitter({ - onFirstListenerDidAdd: this._proxy.$onDidExecuteCommand, - onLastListenerRemove: this._proxy.$disposeListener, + onFirstListenerDidAdd: () => this._proxy.$registerCommandListener(), + onLastListenerRemove: () => this._proxy.$unregisterCommandListener(), }); this.onDidExecuteCommandEmitter = this._onDidExecuteCommand.event; this._logService = logService; From fa406d2dd15cc9bc1fc11cc11843e20180e1c4ed Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Thu, 16 May 2019 09:51:30 -0700 Subject: [PATCH 6/7] tiny tweaks --- src/vs/vscode.proposed.d.ts | 16 +++++++++++----- .../api/browser/mainThreadCommands.ts | 17 +++++++++-------- src/vs/workbench/api/common/extHostCommands.ts | 18 +++++++----------- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index 370c8524198..bd90b412ab1 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -555,16 +555,22 @@ declare module 'vscode' { * @return Disposable which unregisters this command on disposal. */ export function registerDiffInformationCommand(command: string, callback: (diff: LineChange[], ...args: any[]) => any, thisArg?: any): Disposable; + } - export interface ICommandEvent { - commandId: string; - args: any[]; - } + //#endregion + //#region Joh: onDidExecuteCommand + + export interface CommandExecutionEvent { + command: string; + arguments: any[]; + } + + export namespace commands { /** * An event that is emitted when a [command](#Command) is executed. */ - export const onDidExecuteCommand: Event; + export const onDidExecuteCommand: Event; } //#endregion diff --git a/src/vs/workbench/api/browser/mainThreadCommands.ts b/src/vs/workbench/api/browser/mainThreadCommands.ts index 1f63ed47dd0..aab239bebd5 100644 --- a/src/vs/workbench/api/browser/mainThreadCommands.ts +++ b/src/vs/workbench/api/browser/mainThreadCommands.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { ICommandService, CommandsRegistry, ICommandHandlerDescription, ICommandEvent } from 'vs/platform/commands/common/commands'; +import { ICommandService, CommandsRegistry, ICommandHandlerDescription } from 'vs/platform/commands/common/commands'; import { IDisposable } from 'vs/base/common/lifecycle'; import { ExtHostContext, MainThreadCommandsShape, ExtHostCommandsShape, MainContext, IExtHostContext } from '../common/extHost.protocol'; import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers'; @@ -15,7 +15,7 @@ export class MainThreadCommands implements MainThreadCommandsShape { private readonly _disposables = new Map(); private readonly _generateCommandsDocumentationRegistration: IDisposable; private readonly _proxy: ExtHostCommandsShape; - private _onDidExecuteCommandListener: IDisposable; + private _onDidExecuteCommandListener?: IDisposable; constructor( extHostContext: IExtHostContext, @@ -80,20 +80,21 @@ export class MainThreadCommands implements MainThreadCommandsShape { } $registerCommandListener() { - this._onDidExecuteCommandListener = this._commandService.onDidExecuteCommand((command) => this.handleExecuteCommand(command)); + if (!this._onDidExecuteCommandListener) { + this._onDidExecuteCommandListener = this._commandService.onDidExecuteCommand(command => this._proxy.$handleDidExecuteCommand(command)); + } } $unregisterCommandListener() { - return this._onDidExecuteCommandListener.dispose(); + if (this._onDidExecuteCommandListener) { + this._onDidExecuteCommandListener.dispose(); + this._onDidExecuteCommandListener = undefined; + } } $getCommands(): Promise { return Promise.resolve(Object.keys(CommandsRegistry.getCommands())); } - - handleExecuteCommand(command: ICommandEvent) { - this._proxy.$handleDidExecuteCommand(command); - } } // --- command doc diff --git a/src/vs/workbench/api/common/extHostCommands.ts b/src/vs/workbench/api/common/extHostCommands.ts index 2c84c8d03f7..178834dad96 100644 --- a/src/vs/workbench/api/common/extHostCommands.ts +++ b/src/vs/workbench/api/common/extHostCommands.ts @@ -19,7 +19,6 @@ import { Range } from 'vs/editor/common/core/range'; import { Position } from 'vs/editor/common/core/position'; import { URI } from 'vs/base/common/uri'; import { Event, Emitter } from 'vs/base/common/event'; -import { IDisposable } from 'vs/base/common/lifecycle'; interface CommandHandler { callback: Function; @@ -32,8 +31,9 @@ export interface ArgumentProcessor { } export class ExtHostCommands implements ExtHostCommandsShape { - private readonly _onDidExecuteCommand: Emitter; - readonly onDidExecuteCommandEmitter: Event; + + private readonly _onDidExecuteCommand: Emitter; + readonly onDidExecuteCommand: Event; private readonly _commands = new Map(); private readonly _proxy: MainThreadCommandsShape; @@ -47,11 +47,11 @@ export class ExtHostCommands implements ExtHostCommandsShape { logService: ILogService ) { this._proxy = mainContext.getProxy(MainContext.MainThreadCommands); - this._onDidExecuteCommand = new Emitter({ + this._onDidExecuteCommand = new Emitter({ onFirstListenerDidAdd: () => this._proxy.$registerCommandListener(), onLastListenerRemove: () => this._proxy.$unregisterCommandListener(), }); - this.onDidExecuteCommandEmitter = this._onDidExecuteCommand.event; + this.onDidExecuteCommand = this._onDidExecuteCommand.event; this._logService = logService; this._converter = new CommandsConverter(this, heapService); this._argumentProcessors = [ @@ -116,12 +116,8 @@ export class ExtHostCommands implements ExtHostCommandsShape { }); } - onDidExecuteCommand(listener: (command: ICommandEvent) => any, thisArgs?: any, disposables?: IDisposable[]) { - return this.onDidExecuteCommandEmitter(listener, thisArgs, disposables); - } - $handleDidExecuteCommand(command: ICommandEvent): void { - this._onDidExecuteCommand.fire(command); + this._onDidExecuteCommand.fire({ command: command.commandId, arguments: command.args }); } executeCommand(id: string, ...args: any[]): Promise { @@ -172,7 +168,7 @@ export class ExtHostCommands implements ExtHostCommandsShape { try { const result = callback.apply(thisArg, args); - this._onDidExecuteCommand.fire({ commandId: id, args }); + this._onDidExecuteCommand.fire({ command: id, arguments: args }); return Promise.resolve(result); } catch (err) { this._logService.error(err, id); From 4d04ce30d5ac2d733c280966e21b7a1862d90517 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Thu, 16 May 2019 09:52:39 -0700 Subject: [PATCH 7/7] add proposed api check --- src/vs/workbench/api/node/extHost.api.impl.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index 4013345e06a..ef3d3504f91 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -232,6 +232,7 @@ export function createApiFactory( return extHostCommands.getCommands(filterInternal); }, onDidExecuteCommand: proposedApiFunction(extension, (listener, thisArgs?, disposables?) => { + checkProposedApiEnabled(extension); return extHostCommands.onDidExecuteCommand(listener, thisArgs, disposables); }), };