Skip to content

Commit 1828d8a

Browse files
committed
Log warning when menu uses bad commandId
1 parent 4f5dc8f commit 1828d8a

4 files changed

Lines changed: 20 additions & 0 deletions

File tree

src/vs/platform/commands/common/commandService.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,14 @@ export class CommandService implements ICommandService {
3737
}
3838
});
3939
}
40+
41+
isKnownCommand(commandId: string): boolean {
42+
const command = CommandsRegistry.getCommand(commandId);
43+
44+
if (!command) {
45+
return false;
46+
}
47+
48+
return true;
49+
}
4050
}

src/vs/platform/commands/common/commands.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export interface ICommandService {
1414
serviceId: ServiceIdentifier<any>;
1515
executeCommand<T>(commandId: string, ...args: any[]): TPromise<T>;
1616
executeCommand(commandId: string, ...args: any[]): TPromise<any>;
17+
isKnownCommand(commandId: string): boolean;
1718
}
1819

1920
export interface ICommandsMap {
@@ -99,5 +100,8 @@ export const NullCommandService: ICommandService = {
99100
serviceId: undefined,
100101
executeCommand() {
101102
return TPromise.as(undefined);
103+
},
104+
isKnownCommand() {
105+
return false;
102106
}
103107
};

src/vs/workbench/electron-browser/integration.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ export class ElectronIntegration {
172172
private resolveKeybindings(actionIds: string[]): TPromise<{ id: string; binding: number; }[]> {
173173
return this.partService.joinCreation().then(() => {
174174
return arrays.coalesce(actionIds.map((id) => {
175+
if (!this.commandService.isKnownCommand(id)) {
176+
console.warn('Menu uses unknown command: ' + id);
177+
}
175178
let bindings = this.keybindingService.lookupKeybindings(id);
176179

177180
// return the first binding that can be represented by electron

src/vs/workbench/test/node/api/extHostApiCommands.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ suite('ExtHostLanguageFeatureCommands', function() {
6464
executeCommand(id, args): any {
6565
let {handler} = CommandsRegistry.getCommands()[id];
6666
return TPromise.as(instantiationService.invokeFunction(handler, args));
67+
},
68+
isKnownCommand(id) {
69+
return true;
6770
}
6871
});
6972
services.set(IMarkerService, new MarkerService());

0 commit comments

Comments
 (0)