diff --git a/src/vs/editor/browser/standalone/simpleServices.ts b/src/vs/editor/browser/standalone/simpleServices.ts index 0a0a162c3d2..bcef348d3ab 100644 --- a/src/vs/editor/browser/standalone/simpleServices.ts +++ b/src/vs/editor/browser/standalone/simpleServices.ts @@ -15,9 +15,10 @@ import {ConfigurationService, IContent, IStat} from 'vs/platform/configuration/c import {IEditor, IEditorInput, IEditorOptions, IEditorService, IResourceInput, ITextEditorModel, Position} from 'vs/platform/editor/common/editor'; import {AbstractExtensionService, ActivatedExtension} from 'vs/platform/extensions/common/abstractExtensionService'; import {IExtensionDescription} from 'vs/platform/extensions/common/extensions'; +import {ICommandHandler} from 'vs/platform/commands/common/commands'; import {KeybindingService} from 'vs/platform/keybinding/browser/keybindingServiceImpl'; import {IOSupport} from 'vs/platform/keybinding/common/keybindingResolver'; -import {ICommandHandler, ICommandsMap, IKeybindingItem} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingItem} from 'vs/platform/keybinding/common/keybinding'; import {IConfirmation, IMessageService} from 'vs/platform/message/common/message'; import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace'; import * as editorCommon from 'vs/editor/common/editorCommon'; @@ -202,7 +203,7 @@ export class StandaloneKeybindingService extends KeybindingService { private static LAST_GENERATED_ID = 0; private _dynamicKeybindings: IKeybindingItem[]; - private _dynamicCommands: ICommandsMap; + private _dynamicCommands: { [id: string]: ICommandHandler }; constructor(configurationService: IConfigurationService, messageService: IMessageService, domNode: HTMLElement) { super(configurationService, messageService); diff --git a/src/vs/editor/browser/standalone/standaloneCodeEditor.ts b/src/vs/editor/browser/standalone/standaloneCodeEditor.ts index 7aa1ad16298..61b60e346c8 100644 --- a/src/vs/editor/browser/standalone/standaloneCodeEditor.ts +++ b/src/vs/editor/browser/standalone/standaloneCodeEditor.ts @@ -9,7 +9,8 @@ import {IDisposable, dispose} from 'vs/base/common/lifecycle'; import {IContextViewService} from 'vs/platform/contextview/browser/contextView'; import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation'; import {AbstractKeybindingService} from 'vs/platform/keybinding/browser/keybindingServiceImpl'; -import {ICommandHandler, IKeybindingContextKey, IKeybindingService} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingContextKey, IKeybindingService} from 'vs/platform/keybinding/common/keybinding'; +import {ICommandHandler} from 'vs/platform/commands/common/commands'; import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry'; import {IActionDescriptor, ICodeEditorWidgetCreationOptions, IDiffEditorOptions, IModel, IModelChangedEvent, EventType} from 'vs/editor/common/editorCommon'; import {ICodeEditorService} from 'vs/editor/common/services/codeEditorService'; diff --git a/src/vs/editor/common/editorCommonExtensions.ts b/src/vs/editor/common/editorCommonExtensions.ts index ab786e7f98d..f6edaa3878b 100644 --- a/src/vs/editor/common/editorCommonExtensions.ts +++ b/src/vs/editor/common/editorCommonExtensions.ts @@ -9,7 +9,8 @@ import URI from 'vs/base/common/uri'; import {SyncDescriptor1, createSyncDescriptor} from 'vs/platform/instantiation/common/descriptors'; import {ServicesAccessor} from 'vs/platform/instantiation/common/instantiation'; import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation'; -import {ICommandHandler, IKeybindings, KbExpr} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindings, KbExpr} from 'vs/platform/keybinding/common/keybinding'; +import {ICommandHandler} from 'vs/platform/commands/common/commands'; import {ICommandDescriptor, KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry'; import {Registry} from 'vs/platform/platform'; import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry'; diff --git a/src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts b/src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts index 030379c94dc..abd60da00a0 100644 --- a/src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts +++ b/src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts @@ -10,7 +10,8 @@ import URI from 'vs/base/common/uri'; import {TPromise} from 'vs/base/common/winjs.base'; import {IEditorService} from 'vs/platform/editor/common/editor'; import {optional} from 'vs/platform/instantiation/common/instantiation'; -import {ICommandHandler, IKeybindingService, KbExpr} from 'vs/platform/keybinding/common/keybinding'; +import {ICommandHandler} from 'vs/platform/commands/common/commands'; +import {IKeybindingService, KbExpr} from 'vs/platform/keybinding/common/keybinding'; import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry'; import {Position} from 'vs/editor/common/core/position'; import {Range} from 'vs/editor/common/core/range'; diff --git a/src/vs/platform/commands/common/commands.ts b/src/vs/platform/commands/common/commands.ts new file mode 100644 index 00000000000..fc4350078b5 --- /dev/null +++ b/src/vs/platform/commands/common/commands.ts @@ -0,0 +1,128 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +'use strict'; + +import {TPromise} from 'vs/base/common/winjs.base'; +import {TypeConstraint, validateConstraints} from 'vs/base/common/types'; +import {IInstantiationService, ServicesAccessor, createDecorator} from 'vs/platform/instantiation/common/instantiation'; +import {registerSingleton} from 'vs/platform/instantiation/common/extensions'; +import {IExtensionService} from 'vs/platform/extensions/common/extensions'; + +export const ICommandService = createDecorator('commandService'); + +export interface ICommandService { + executeCommand(commandId: string, ...args: any[]): TPromise; + executeCommand(commandId: string, ...args: any[]): TPromise; +} + +export interface ICommandsMap { + [id: string]: ICommand; +} + +export interface ICommandHandler { + (accessor: ServicesAccessor, ...args: any[]): void; +} + +export interface ICommand { + handler: ICommandHandler; + description?: ICommandHandlerDescription; +} + +export interface ICommandHandlerDescription { + description: string; + args: { name: string; description?: string; constraint?: TypeConstraint; }[]; + returns?: string; +} + +export interface ICommandRegistry { + registerCommand(id: string, command: ICommandHandler): void; + registerCommand(id: string, command: ICommand): void; + getCommand(id: string): ICommand; + getCommands(): ICommandsMap; +} + +function isCommand(thing: any): thing is ICommand { + return typeof thing === 'object' + && typeof (thing).handler === 'function' + && (!(thing).description || typeof (thing).description === 'object'); +} + +export const CommandsRegistry: ICommandRegistry = new class implements ICommandRegistry { + + private _commands: { [id: string]: ICommand } = Object.create(null); + + registerCommand(id: string, commandOrDesc: ICommandHandler | ICommand): void { + // if (this._commands[id] !== void 0) { + // throw new Error(`command already exists: '${id}'`); + // } + if (!commandOrDesc) { + throw new Error(`invalid command`); + } + + if (!isCommand(commandOrDesc)) { + // simple handler + this._commands[id] = { handler: commandOrDesc }; + + } else { + const {handler, description} = commandOrDesc; + if (description) { + // add argument validation if rich command metadata is provided + const constraints: TypeConstraint[] = []; + for (let arg of description.args) { + constraints.push(arg.constraint); + } + this._commands[id] = { + description, + handler(accessor, ...args: any[]) { + validateConstraints(args, constraints); + return handler(accessor, ...args); + } + }; + } else { + // add as simple handler + this._commands[id] = { handler }; + } + } + } + + getCommand(id: string): ICommand { + return this._commands[id]; + } + + getCommands(): ICommandsMap { + return this._commands; + } +}; + +class DefaultCommandService implements ICommandService { + + serviceId: any; + + constructor( + @IInstantiationService private _instantiationService: IInstantiationService, + @IExtensionService private _extensionService: IExtensionService + ) { + // + } + + executeCommand(id: string, ...args: any[]): TPromise { + + const command = CommandsRegistry.getCommand(id); + if (!command) { + return TPromise.wrapError(new Error(`command '${id}' not found`)); + } + + this._extensionService.activateByEvent(`onCommand:${id}`).then(_ => { + try { + const result = this._instantiationService.invokeFunction.apply(this._instantiationService, [command].concat(args)); + return TPromise.as(result); + } catch (err) { + return TPromise.wrapError(err); + } + }); + } +} + +registerSingleton(ICommandService, DefaultCommandService); diff --git a/src/vs/platform/commands/test/commands.test.ts b/src/vs/platform/commands/test/commands.test.ts new file mode 100644 index 00000000000..4252eb226f3 --- /dev/null +++ b/src/vs/platform/commands/test/commands.test.ts @@ -0,0 +1,22 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +'use strict'; + +import * as assert from 'assert'; +import {CommandsRegistry} from 'vs/platform/commands/common/commands'; + + +suite('Command Tests', function () { + + test('register command - no handler', function () { + assert.throws(() => CommandsRegistry.registerCommand('foo', null)); + }); + + // test('register command - dupe', function () { + // CommandsRegistry.registerCommand('foo', () => { }); + // assert.throws(() => CommandsRegistry.registerCommand('foo', () => { })); + // }); + +}); \ No newline at end of file diff --git a/src/vs/platform/keybinding/browser/keybindingServiceImpl.ts b/src/vs/platform/keybinding/browser/keybindingServiceImpl.ts index 192a48e0385..b2f3bff44d1 100644 --- a/src/vs/platform/keybinding/browser/keybindingServiceImpl.ts +++ b/src/vs/platform/keybinding/browser/keybindingServiceImpl.ts @@ -15,8 +15,9 @@ import {TPromise} from 'vs/base/common/winjs.base'; import * as dom from 'vs/base/browser/dom'; import {IKeyboardEvent, StandardKeyboardEvent} from 'vs/base/browser/keyboardEvent'; import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation'; +import {CommandsRegistry, ICommandHandler, ICommandHandlerDescription} from 'vs/platform/commands/common/commands'; import {KeybindingResolver} from 'vs/platform/keybinding/common/keybindingResolver'; -import {ICommandHandler, ICommandHandlerDescription, IKeybindingContextKey, IKeybindingItem, IKeybindingScopeLocation, IKeybindingService, SET_CONTEXT_COMMAND_ID, KbExpr} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingContextKey, IKeybindingItem, IKeybindingScopeLocation, IKeybindingService, SET_CONTEXT_COMMAND_ID, KbExpr} from 'vs/platform/keybinding/common/keybinding'; import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry'; import {IStatusbarService} from 'vs/platform/statusbar/common/statusbar'; import {IMessageService} from 'vs/platform/message/common/message'; @@ -207,7 +208,7 @@ export abstract class AbstractKeybindingService { } public hasCommand(commandId: string): boolean { - return !!KeybindingsRegistry.getCommands()[commandId]; + return !!CommandsRegistry.getCommands()[commandId]; } public abstract executeCommand(commandId: string, args: any): TPromise; @@ -312,7 +313,7 @@ export abstract class KeybindingService extends AbstractKeybindingService implem } private _getAllCommandsAsComment(): string { - const commands = KeybindingsRegistry.getCommands(); + const commands = CommandsRegistry.getCommands(); const unboundCommands: string[] = []; const boundCommands = this._getResolver().getDefaultBoundCommands(); @@ -336,7 +337,7 @@ export abstract class KeybindingService extends AbstractKeybindingService implem } protected _getCommandHandler(commandId: string): ICommandHandler { - return KeybindingsRegistry.getCommands()[commandId]; + return CommandsRegistry.getCommand(commandId).handler; } private _dispatch(e: IKeyboardEvent): void { diff --git a/src/vs/platform/keybinding/common/keybinding.ts b/src/vs/platform/keybinding/common/keybinding.ts index c86eaba0b64..f32ee280094 100644 --- a/src/vs/platform/keybinding/common/keybinding.ts +++ b/src/vs/platform/keybinding/common/keybinding.ts @@ -6,9 +6,8 @@ import {IHTMLContentElement} from 'vs/base/common/htmlContent'; import {Keybinding} from 'vs/base/common/keyCodes'; -import {TypeConstraint} from 'vs/base/common/types'; import {TPromise} from 'vs/base/common/winjs.base'; -import {ServiceIdentifier, ServicesAccessor, createDecorator} from 'vs/platform/instantiation/common/instantiation'; +import {ServiceIdentifier, createDecorator} from 'vs/platform/instantiation/common/instantiation'; import Event from 'vs/base/common/event'; export interface IUserFriendlyKeybinding { @@ -436,21 +435,6 @@ export interface IKeybindingItem { weight2: number; } -export interface ICommandHandler { - (accessor: ServicesAccessor, ...args: any[]): void; - description?: string | ICommandHandlerDescription; -} - -export interface ICommandHandlerDescription { - description: string; - args: { name: string; description?: string; constraint?: TypeConstraint; }[]; - returns?: string; -} - -export interface ICommandsMap { - [id: string]: ICommandHandler; -} - export interface IKeybindingContextKey { set(value: T): void; reset(): void; diff --git a/src/vs/platform/keybinding/common/keybindingsRegistry.ts b/src/vs/platform/keybinding/common/keybindingsRegistry.ts index 36c5d7e2638..b35094404c5 100644 --- a/src/vs/platform/keybinding/common/keybindingsRegistry.ts +++ b/src/vs/platform/keybinding/common/keybindingsRegistry.ts @@ -6,8 +6,8 @@ import {BinaryKeybindings, KeyCode} from 'vs/base/common/keyCodes'; import * as platform from 'vs/base/common/platform'; -import {TypeConstraint, validateConstraints} from 'vs/base/common/types'; -import {ICommandHandler, ICommandHandlerDescription, ICommandsMap, IKeybindingItem, IKeybindings, KbExpr} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingItem, IKeybindings, KbExpr} from 'vs/platform/keybinding/common/keybinding'; +import {CommandsRegistry, ICommandHandler, ICommandHandlerDescription} from 'vs/platform/commands/common/commands'; import {Registry} from 'vs/platform/platform'; export interface ICommandRule extends IKeybindings { @@ -18,13 +18,12 @@ export interface ICommandRule extends IKeybindings { export interface ICommandDescriptor extends ICommandRule { handler: ICommandHandler; - description?: string | ICommandHandlerDescription; + description?: ICommandHandlerDescription; } export interface IKeybindingsRegistry { registerCommandRule(rule: ICommandRule); registerCommandDesc(desc: ICommandDescriptor): void; - getCommands(): ICommandsMap; getDefaultKeybindings(): IKeybindingItem[]; WEIGHT: { @@ -39,7 +38,6 @@ export interface IKeybindingsRegistry { class KeybindingsRegistryImpl implements IKeybindingsRegistry { private _keybindings: IKeybindingItem[]; - private _commands: ICommandsMap; public WEIGHT = { editorCore: (importance: number = 0): number => { @@ -61,7 +59,6 @@ class KeybindingsRegistryImpl implements IKeybindingsRegistry { constructor() { this._keybindings = []; - this._commands = Object.create(null); } /** @@ -101,36 +98,7 @@ class KeybindingsRegistryImpl implements IKeybindingsRegistry { public registerCommandDesc(desc: ICommandDescriptor): void { this.registerCommandRule(desc); - - // if (_commands[desc.id]) { - // console.warn('Duplicate handler for command: ' + desc.id); - // } - // this._commands[desc.id] = desc.handler; - - let handler = desc.handler; - let description = desc.description || handler.description; - - // add argument validation if rich command metadata is provided - if (typeof description === 'object') { - let constraints: TypeConstraint[] = []; - for (let arg of description.args) { - constraints.push(arg.constraint); - } - handler = function (accesor, ...args: any[]) { - validateConstraints(args, constraints); - return desc.handler(accesor, ...args); - }; - } - - // make sure description is there - handler.description = description; - - // register handler - this._commands[desc.id] = handler; - } - - public getCommands(): ICommandsMap { - return this._commands; + CommandsRegistry.registerCommand(desc.id, desc); } private registerDefaultKeybinding(keybinding: number, commandId: string, weight1: number, weight2: number, when: KbExpr): void { diff --git a/src/vs/platform/keybinding/test/common/keybindingsRegistry.test.ts b/src/vs/platform/keybinding/test/common/keybindingsRegistry.test.ts index fc0f110000f..0f00100a26c 100644 --- a/src/vs/platform/keybinding/test/common/keybindingsRegistry.test.ts +++ b/src/vs/platform/keybinding/test/common/keybindingsRegistry.test.ts @@ -6,6 +6,7 @@ import * as assert from 'assert'; import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry'; +import {CommandsRegistry} from 'vs/platform/commands/common/commands'; suite('Keybinding Registry', () => { @@ -23,7 +24,6 @@ suite('Keybinding Registry', () => { KeybindingsRegistry.registerCommandDesc({ id: 'test2', - description: 'test', when: undefined, primary: undefined, weight: 0, @@ -46,10 +46,10 @@ suite('Keybinding Registry', () => { } }); - KeybindingsRegistry.getCommands()['test'].apply(undefined, [undefined, 'string']); - KeybindingsRegistry.getCommands()['test2'].apply(undefined, [undefined, 'string']); - assert.throws(() => KeybindingsRegistry.getCommands()['test3'].apply(undefined, [undefined, 'string'])); - assert.equal(KeybindingsRegistry.getCommands()['test3'].apply(undefined, [undefined, 1]), true); + CommandsRegistry.getCommands()['test'].handler.apply(undefined, [undefined, 'string']); + CommandsRegistry.getCommands()['test2'].handler.apply(undefined, [undefined, 'string']); + assert.throws(() => CommandsRegistry.getCommands()['test3'].handler.apply(undefined, [undefined, 'string'])); + assert.equal(CommandsRegistry.getCommands()['test3'].handler.apply(undefined, [undefined, 1]), true); }); }); diff --git a/src/vs/workbench/api/node/extHostApiCommands.ts b/src/vs/workbench/api/node/extHostApiCommands.ts index ceecbe9b493..5e5899bd92b 100644 --- a/src/vs/workbench/api/node/extHostApiCommands.ts +++ b/src/vs/workbench/api/node/extHostApiCommands.ts @@ -12,7 +12,7 @@ import * as typeConverters from 'vs/workbench/api/node/extHostTypeConverters'; import * as types from 'vs/workbench/api/node/extHostTypes'; import {ISingleEditOperation} from 'vs/editor/common/editorCommon'; import * as modes from 'vs/editor/common/modes'; -import {ICommandHandlerDescription} from 'vs/platform/keybinding/common/keybinding'; +import {ICommandHandlerDescription} from 'vs/platform/commands/common/commands'; import {ExtHostCommands} from 'vs/workbench/api/node/extHostCommands'; import {IQuickFix2} from 'vs/editor/contrib/quickFix/common/quickFix'; import {IOutline} from 'vs/editor/contrib/quickOpen/common/quickOpen'; diff --git a/src/vs/workbench/api/node/extHostCommands.ts b/src/vs/workbench/api/node/extHostCommands.ts index 5b2b1874f9a..d3480cde4dc 100644 --- a/src/vs/workbench/api/node/extHostCommands.ts +++ b/src/vs/workbench/api/node/extHostCommands.ts @@ -6,7 +6,7 @@ import {IThreadService} from 'vs/workbench/services/thread/common/threadService'; import {validateConstraint} from 'vs/base/common/types'; -import {ICommandHandlerDescription} from 'vs/platform/keybinding/common/keybinding'; +import {ICommandHandlerDescription} from 'vs/platform/commands/common/commands'; import {TPromise} from 'vs/base/common/winjs.base'; import {ExtHostEditors} from 'vs/workbench/api/node/extHostEditors'; import * as extHostTypes from 'vs/workbench/api/node/extHostTypes'; diff --git a/src/vs/workbench/api/node/extHostProtocol.ts b/src/vs/workbench/api/node/extHostProtocol.ts index c496c33f668..b55b4c879b6 100644 --- a/src/vs/workbench/api/node/extHostProtocol.ts +++ b/src/vs/workbench/api/node/extHostProtocol.ts @@ -21,7 +21,7 @@ import {Position as EditorPosition} from 'vs/platform/editor/common/editor'; import {IMessage, IExtensionDescription} from 'vs/platform/extensions/common/extensions'; import {StatusbarAlignment as MainThreadStatusBarAlignment} from 'vs/platform/statusbar/common/statusbar'; import {ITelemetryInfo} from 'vs/platform/telemetry/common/telemetry'; -import {ICommandHandlerDescription} from 'vs/platform/keybinding/common/keybinding'; +import {ICommandHandlerDescription} from 'vs/platform/commands/common/commands'; import * as editorCommon from 'vs/editor/common/editorCommon'; import * as modes from 'vs/editor/common/modes'; diff --git a/src/vs/workbench/api/node/mainThreadCommands.ts b/src/vs/workbench/api/node/mainThreadCommands.ts index 582e65cedfa..08cc893704a 100644 --- a/src/vs/workbench/api/node/mainThreadCommands.ts +++ b/src/vs/workbench/api/node/mainThreadCommands.ts @@ -6,7 +6,9 @@ import {IThreadService} from 'vs/workbench/services/thread/common/threadService'; import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry'; -import {IKeybindingService, ICommandHandlerDescription} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService} from 'vs/platform/keybinding/common/keybinding'; +import {CommandsRegistry, ICommandHandlerDescription} from 'vs/platform/commands/common/commands'; + import {TPromise} from 'vs/base/common/winjs.base'; import {ExtHostContext, ExtHostCommandsShape} from './extHostProtocol'; @@ -49,7 +51,7 @@ export class MainThreadCommands { } $getCommands(): Thenable { - return TPromise.as(Object.keys(KeybindingsRegistry.getCommands())); + return TPromise.as(Object.keys(CommandsRegistry.getCommands())); } } @@ -61,7 +63,7 @@ KeybindingsRegistry.registerCommandDesc({ return accessor.get(IThreadService).get(ExtHostContext.ExtHostCommands).$getContributedCommandHandlerDescriptions().then(result => { // add local commands - const commands = KeybindingsRegistry.getCommands(); + const commands = CommandsRegistry.getCommands(); for (let id in commands) { let {description} = commands[id]; if (description) { diff --git a/src/vs/workbench/common/actionRegistry.ts b/src/vs/workbench/common/actionRegistry.ts index 3f611281935..6255e94e57e 100644 --- a/src/vs/workbench/common/actionRegistry.ts +++ b/src/vs/workbench/common/actionRegistry.ts @@ -10,7 +10,7 @@ import {Registry} from 'vs/platform/platform'; import {IAction} from 'vs/base/common/actions'; import {KeybindingsRegistry, ICommandDescriptor} from 'vs/platform/keybinding/common/keybindingsRegistry'; import {IPartService} from 'vs/workbench/services/part/common/partService'; -import {ICommandHandler} from 'vs/platform/keybinding/common/keybinding'; +import {ICommandHandler} from 'vs/platform/commands/common/commands'; import {SyncActionDescriptor} from 'vs/platform/actions/common/actions'; import {IMessageService} from 'vs/platform/message/common/message'; import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry'; diff --git a/src/vs/workbench/test/node/api/extHostApiCommands.test.ts b/src/vs/workbench/test/node/api/extHostApiCommands.test.ts index 3b3805ba8b9..c0893e17cf0 100644 --- a/src/vs/workbench/test/node/api/extHostApiCommands.test.ts +++ b/src/vs/workbench/test/node/api/extHostApiCommands.test.ts @@ -19,7 +19,7 @@ import {MarkerService} from 'vs/platform/markers/common/markerService'; import {IMarkerService} from 'vs/platform/markers/common/markers'; import {IThreadService} from 'vs/workbench/services/thread/common/threadService'; import {IKeybindingService} from 'vs/platform/keybinding/common/keybinding'; -import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry'; +import {CommandsRegistry} from 'vs/platform/commands/common/commands'; import {IModelService} from 'vs/editor/common/services/modelService'; import {ExtHostLanguageFeatures} from 'vs/workbench/api/node/extHostLanguageFeatures'; import {MainThreadLanguageFeatures} from 'vs/workbench/api/node/mainThreadLanguageFeatures'; @@ -62,7 +62,7 @@ suite('ExtHostLanguageFeatureCommands', function() { services.set(IKeybindingService, { executeCommand(id, args): any { - let handler = KeybindingsRegistry.getCommands()[id]; + let {handler} = CommandsRegistry.getCommands()[id]; return TPromise.as(instantiationService.invokeFunction(handler, args)); } });