Skip to content

Commit 4226440

Browse files
authored
Fix startup performance (microsoft#210553)
1 parent 5575ca4 commit 4226440

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

src/vs/platform/actions/common/menuService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,13 +443,13 @@ function createMenuHide(menu: MenuId, command: ICommandAction | ISubmenuItem, st
443443
}
444444

445445
export function createConfigureKeybindingAction(commandId: string, when: ContextKeyExpression | undefined = undefined, commandService: ICommandService, keybindingService: IKeybindingService): IAction {
446-
const hasKeybinding = !!keybindingService.lookupKeybinding(commandId);
447446
return toAction({
448447
id: `configureKeybinding/${commandId}`,
449-
label: hasKeybinding ? localize('change keybinding', "Change Keybinding") : localize('configure keybinding', "Configure Keybinding"),
448+
label: localize('configure keybinding', "Configure Keybinding"),
450449
run() {
451450
// Only set the when clause when there is no keybinding
452451
// It is possible that the action and the keybinding have different when clauses
452+
const hasKeybinding = !!keybindingService.lookupKeybinding(commandId); // This may only be called inside the `run()` method as it can be expensive on startup. #210529
453453
const whenValue = !hasKeybinding && when ? when.serialize() : undefined;
454454
commandService.executeCommand('workbench.action.openGlobalKeybindings', `@command:${commandId}` + (whenValue ? ` +when:${whenValue}` : ''));
455455
}

src/vs/workbench/contrib/quickaccess/browser/commandsQuickAccess.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -126,20 +126,17 @@ export class CommandsQuickAccessProvider extends AbstractEditorCommandsQuickAcce
126126
return [
127127
...this.getCodeEditorCommandPicks(),
128128
...this.getGlobalCommandPicks()
129-
].map(picks => {
130-
const hasKeybinding = !!this.keybindingService.lookupKeybindings(picks.commandId);
131-
return {
132-
...picks,
133-
buttons: [{
134-
iconClass: ThemeIcon.asClassName(Codicon.gear),
135-
tooltip: hasKeybinding ? localize('change keybinding', "Change Keybinding") : localize('configure keybinding', "Configure Keybinding"),
136-
}],
137-
trigger: (): TriggerAction => {
138-
this.preferencesService.openGlobalKeybindingSettings(false, { query: createKeybindingCommandQuery(picks.commandId, picks.commandWhen) });
139-
return TriggerAction.CLOSE_PICKER;
140-
},
141-
};
142-
});
129+
].map(picks => ({
130+
...picks,
131+
buttons: [{
132+
iconClass: ThemeIcon.asClassName(Codicon.gear),
133+
tooltip: localize('configure keybinding', "Configure Keybinding"),
134+
}],
135+
trigger: (): TriggerAction => {
136+
this.preferencesService.openGlobalKeybindingSettings(false, { query: createKeybindingCommandQuery(picks.commandId, picks.commandWhen) });
137+
return TriggerAction.CLOSE_PICKER;
138+
},
139+
}));
143140
}
144141

145142
protected hasAdditionalCommandPicks(filter: string, token: CancellationToken): boolean {

0 commit comments

Comments
 (0)