Skip to content

Commit 85f13f9

Browse files
authored
Refactor createConfigureKeybindingAction to support disabling keybinding configuration for SCM statusbar actions (microsoft#218372)
chore: refactor createConfigureKeybindingAction to support disabling keybinding configuration for scm statusbar actions
1 parent 7ebe6d3 commit 85f13f9

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/vs/platform/actions/browser/toolbar.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ export class WorkbenchToolBar extends ToolBar {
202202
if (action instanceof MenuItemAction && action.menuKeybinding) {
203203
primaryActions.push(action.menuKeybinding);
204204
} else if (!(action instanceof SubmenuItemAction || action instanceof ToggleMenuAction)) {
205-
primaryActions.push(createConfigureKeybindingAction(action.id, undefined, this._commandService, this._keybindingService));
205+
const isDisabled = action.id.startsWith('statusbaraction'); // We can't support keybinding configuration for scm statusbar actions
206+
primaryActions.push(createConfigureKeybindingAction(this._commandService, this._keybindingService, action.id, undefined, !isDisabled));
206207
}
207208

208209
// -- Hide Actions --

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ class MenuInfo {
248248
const menuHide = createMenuHide(this._id, isMenuItem ? item.command : item, this._hiddenStates);
249249
if (isMenuItem) {
250250
// MenuItemAction
251-
const menuKeybinding = createConfigureKeybindingAction(item.command.id, item.when, this._commandService, this._keybindingService);
251+
const menuKeybinding = createConfigureKeybindingAction(this._commandService, this._keybindingService, item.command.id, item.when);
252252
(activeActions ??= []).push(new MenuItemAction(item.command, item.alt, options, menuHide, menuKeybinding, this._contextKeyService, this._commandService));
253253
} else {
254254
// SubmenuItemAction
@@ -442,10 +442,11 @@ function createMenuHide(menu: MenuId, command: ICommandAction | ISubmenuItem, st
442442
};
443443
}
444444

445-
export function createConfigureKeybindingAction(commandId: string, when: ContextKeyExpression | undefined = undefined, commandService: ICommandService, keybindingService: IKeybindingService): IAction {
445+
export function createConfigureKeybindingAction(commandService: ICommandService, keybindingService: IKeybindingService, commandId: string, when: ContextKeyExpression | undefined = undefined, enabled = true): IAction {
446446
return toAction({
447447
id: `configureKeybinding/${commandId}`,
448448
label: localize('configure keybinding', "Configure Keybinding"),
449+
enabled,
449450
run() {
450451
// Only set the when clause when there is no keybinding
451452
// It is possible that the action and the keybinding have different when clauses

0 commit comments

Comments
 (0)