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

Make executeCommand return a promise

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