Skip to content

Commit bedec88

Browse files
committed
Make executeCommand return a promise
1 parent 8f0ec19 commit bedec88

4 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/vs/platform/keybinding/browser/keybindingServiceImpl.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export class AbstractKeybindingService {
142142
throw new Error('Not implemented');
143143
}
144144

145-
public executeCommand(commandId: string, args:any): void {
145+
public executeCommand(commandId: string, args:any): TPromise<any> {
146146
throw new Error('Not implemented');
147147
}
148148
}
@@ -300,7 +300,7 @@ export class KeybindingService extends AbstractKeybindingService implements IKey
300300
delete this._contexts[String(contextId)];
301301
}
302302

303-
public executeCommand(commandId: string, args:any = {}): any {
303+
public executeCommand(commandId: string, args:any = {}): TPromise<any> {
304304
if (!args.context) {
305305
var contextId = this._findContextAttr(<HTMLElement>document.activeElement);
306306
var context = this.getContext(contextId);
@@ -309,9 +309,7 @@ export class KeybindingService extends AbstractKeybindingService implements IKey
309309
args.context = contextValue;
310310
}
311311

312-
return this._invokeHandler(commandId, args).done(undefined, err => {
313-
this._messageService.show(Severity.Warning, err);
314-
});
312+
return this._invokeHandler(commandId, args);
315313
}
316314
}
317315

@@ -356,8 +354,8 @@ class ScopedKeybindingService extends AbstractKeybindingService {
356354
this._parent.disposeContext(contextId);
357355
}
358356

359-
public executeCommand(commandId: string, args:any): void {
360-
this._parent.executeCommand(commandId, args);
357+
public executeCommand(commandId: string, args:any): TPromise<any> {
358+
return this._parent.executeCommand(commandId, args);
361359
}
362360
}
363361

src/vs/platform/keybinding/common/keybindingService.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55
'use strict';
66

7+
import {TPromise} from 'vs/base/common/winjs.base';
78
import {createDecorator, IInstantiationService, ServiceIdentifier, ServicesAccessor} from 'vs/platform/instantiation/common/instantiation';
89
import {Keybinding} from 'vs/base/common/keyCodes';
910

@@ -82,5 +83,6 @@ export interface IKeybindingService {
8283
lookupKeybindings(commandId: string): Keybinding[];
8384
customKeybindingsCount(): number;
8485

85-
executeCommand(commandId: string, args?: any): any;
86+
executeCommand<T>(commandId: string, args?: any): TPromise<T>;
87+
executeCommand(commandId: string, args?: any): TPromise<any>;
8688
}

src/vs/workbench/api/common/pluginHostCommands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export class MainThreadCommands {
148148
}
149149

150150
_executeCommand<T>(id: string, args: any[]): Thenable<T> {
151-
return TPromise.as(this._keybindingService.executeCommand(id, args));
151+
return this._keybindingService.executeCommand(id, args);
152152
}
153153

154154
_getCommands(): Thenable<string[]> {

src/vs/workbench/test/browser/servicesTestUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export class TestKeybindingService implements IKeybindingService {
153153
public setInstantiationService(instantiationService: IInstantiationService): void { }
154154
public setContext(key: string, value: any): void { }
155155
public removeContext(key: string): void { }
156-
public executeCommand(commandId: string, args: any): void { }
156+
public executeCommand(commandId: string, args: any): TPromise<any> { return; }
157157

158158
public createKey<T>(key: string, defaultValue: T): IKeybindingContextKey<T> {
159159
return null;

0 commit comments

Comments
 (0)