提交 1828d8a7 编写于 作者: A Alex Dima

Log warning when menu uses bad `commandId`

上级 4f5dc8f0
......@@ -37,4 +37,14 @@ export class CommandService implements ICommandService {
}
});
}
isKnownCommand(commandId: string): boolean {
const command = CommandsRegistry.getCommand(commandId);
if (!command) {
return false;
}
return true;
}
}
......@@ -14,6 +14,7 @@ export interface ICommandService {
serviceId: ServiceIdentifier<any>;
executeCommand<T>(commandId: string, ...args: any[]): TPromise<T>;
executeCommand(commandId: string, ...args: any[]): TPromise<any>;
isKnownCommand(commandId: string): boolean;
}
export interface ICommandsMap {
......@@ -99,5 +100,8 @@ export const NullCommandService: ICommandService = {
serviceId: undefined,
executeCommand() {
return TPromise.as(undefined);
},
isKnownCommand() {
return false;
}
};
\ No newline at end of file
......@@ -172,6 +172,9 @@ export class ElectronIntegration {
private resolveKeybindings(actionIds: string[]): TPromise<{ id: string; binding: number; }[]> {
return this.partService.joinCreation().then(() => {
return arrays.coalesce(actionIds.map((id) => {
if (!this.commandService.isKnownCommand(id)) {
console.warn('Menu uses unknown command: ' + id);
}
let bindings = this.keybindingService.lookupKeybindings(id);
// return the first binding that can be represented by electron
......
......@@ -64,6 +64,9 @@ suite('ExtHostLanguageFeatureCommands', function() {
executeCommand(id, args): any {
let {handler} = CommandsRegistry.getCommands()[id];
return TPromise.as(instantiationService.invokeFunction(handler, args));
},
isKnownCommand(id) {
return true;
}
});
services.set(IMarkerService, new MarkerService());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册