提交 bedec883 编写于 作者: J Johannes Rieken

Make executeCommand return a promise

上级 8f0ec19a
......@@ -142,7 +142,7 @@ export class AbstractKeybindingService {
throw new Error('Not implemented');
}
public executeCommand(commandId: string, args:any): void {
public executeCommand(commandId: string, args:any): TPromise<any> {
throw new Error('Not implemented');
}
}
......@@ -300,7 +300,7 @@ export class KeybindingService extends AbstractKeybindingService implements IKey
delete this._contexts[String(contextId)];
}
public executeCommand(commandId: string, args:any = {}): any {
public executeCommand(commandId: string, args:any = {}): TPromise<any> {
if (!args.context) {
var contextId = this._findContextAttr(<HTMLElement>document.activeElement);
var context = this.getContext(contextId);
......@@ -309,9 +309,7 @@ export class KeybindingService extends AbstractKeybindingService implements IKey
args.context = contextValue;
}
return this._invokeHandler(commandId, args).done(undefined, err => {
this._messageService.show(Severity.Warning, err);
});
return this._invokeHandler(commandId, args);
}
}
......@@ -356,8 +354,8 @@ class ScopedKeybindingService extends AbstractKeybindingService {
this._parent.disposeContext(contextId);
}
public executeCommand(commandId: string, args:any): void {
this._parent.executeCommand(commandId, args);
public executeCommand(commandId: string, args:any): TPromise<any> {
return this._parent.executeCommand(commandId, args);
}
}
......
......@@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import {TPromise} from 'vs/base/common/winjs.base';
import {createDecorator, IInstantiationService, ServiceIdentifier, ServicesAccessor} from 'vs/platform/instantiation/common/instantiation';
import {Keybinding} from 'vs/base/common/keyCodes';
......@@ -82,5 +83,6 @@ export interface IKeybindingService {
lookupKeybindings(commandId: string): Keybinding[];
customKeybindingsCount(): number;
executeCommand(commandId: string, args?: any): any;
executeCommand<T>(commandId: string, args?: any): TPromise<T>;
executeCommand(commandId: string, args?: any): TPromise<any>;
}
......@@ -148,7 +148,7 @@ export class MainThreadCommands {
}
_executeCommand<T>(id: string, args: any[]): Thenable<T> {
return TPromise.as(this._keybindingService.executeCommand(id, args));
return this._keybindingService.executeCommand(id, args);
}
_getCommands(): Thenable<string[]> {
......
......@@ -153,7 +153,7 @@ export class TestKeybindingService implements IKeybindingService {
public setInstantiationService(instantiationService: IInstantiationService): void { }
public setContext(key: string, value: any): void { }
public removeContext(key: string): void { }
public executeCommand(commandId: string, args: any): void { }
public executeCommand(commandId: string, args: any): TPromise<any> { return; }
public createKey<T>(key: string, defaultValue: T): IKeybindingContextKey<T> {
return null;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册