diff --git a/src/vs/platform/commands/common/commandService.ts b/src/vs/platform/commands/common/commandService.ts index c3844d25288bdc84dc6a329317c3bad30ee35187..2821e462d41746419162693eff7675a7b50f8f30 100644 --- a/src/vs/platform/commands/common/commandService.ts +++ b/src/vs/platform/commands/common/commandService.ts @@ -37,4 +37,14 @@ export class CommandService implements ICommandService { } }); } + + isKnownCommand(commandId: string): boolean { + const command = CommandsRegistry.getCommand(commandId); + + if (!command) { + return false; + } + + return true; + } } diff --git a/src/vs/platform/commands/common/commands.ts b/src/vs/platform/commands/common/commands.ts index 0dbb3c3b3133b72077eea3e8fd99e35510413ff9..1c4542c95953a475fdc55cbdeddc8b3063d8b598 100644 --- a/src/vs/platform/commands/common/commands.ts +++ b/src/vs/platform/commands/common/commands.ts @@ -14,6 +14,7 @@ export interface ICommandService { serviceId: ServiceIdentifier; executeCommand(commandId: string, ...args: any[]): TPromise; executeCommand(commandId: string, ...args: any[]): TPromise; + 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 diff --git a/src/vs/workbench/electron-browser/integration.ts b/src/vs/workbench/electron-browser/integration.ts index faaa4c2d47e675169d9b6f75dd0198f28bb386c5..8576845fb54372dd2928962217dd32ac860f9ee0 100644 --- a/src/vs/workbench/electron-browser/integration.ts +++ b/src/vs/workbench/electron-browser/integration.ts @@ -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 diff --git a/src/vs/workbench/test/node/api/extHostApiCommands.test.ts b/src/vs/workbench/test/node/api/extHostApiCommands.test.ts index ccf5af8b225b7c4e5c90007c3b4c98c6151da234..dc5b8b05625b464a92bc19cc570f0756b03dbaf0 100644 --- a/src/vs/workbench/test/node/api/extHostApiCommands.test.ts +++ b/src/vs/workbench/test/node/api/extHostApiCommands.test.ts @@ -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());