mirror of
https://github.com/Microsoft/vscode
synced 2024-10-01 08:50:48 +00:00
Refactor createConfigureKeybindingAction to support disabling keybinding configuration for SCM statusbar actions (#218372)
chore: refactor createConfigureKeybindingAction to support disabling keybinding configuration for scm statusbar actions
This commit is contained in:
parent
7ebe6d364f
commit
85f13f93f1
|
@ -202,7 +202,8 @@ export class WorkbenchToolBar extends ToolBar {
|
|||
if (action instanceof MenuItemAction && action.menuKeybinding) {
|
||||
primaryActions.push(action.menuKeybinding);
|
||||
} else if (!(action instanceof SubmenuItemAction || action instanceof ToggleMenuAction)) {
|
||||
primaryActions.push(createConfigureKeybindingAction(action.id, undefined, this._commandService, this._keybindingService));
|
||||
const isDisabled = action.id.startsWith('statusbaraction'); // We can't support keybinding configuration for scm statusbar actions
|
||||
primaryActions.push(createConfigureKeybindingAction(this._commandService, this._keybindingService, action.id, undefined, !isDisabled));
|
||||
}
|
||||
|
||||
// -- Hide Actions --
|
||||
|
|
|
@ -248,7 +248,7 @@ class MenuInfo {
|
|||
const menuHide = createMenuHide(this._id, isMenuItem ? item.command : item, this._hiddenStates);
|
||||
if (isMenuItem) {
|
||||
// MenuItemAction
|
||||
const menuKeybinding = createConfigureKeybindingAction(item.command.id, item.when, this._commandService, this._keybindingService);
|
||||
const menuKeybinding = createConfigureKeybindingAction(this._commandService, this._keybindingService, item.command.id, item.when);
|
||||
(activeActions ??= []).push(new MenuItemAction(item.command, item.alt, options, menuHide, menuKeybinding, this._contextKeyService, this._commandService));
|
||||
} else {
|
||||
// SubmenuItemAction
|
||||
|
@ -442,10 +442,11 @@ function createMenuHide(menu: MenuId, command: ICommandAction | ISubmenuItem, st
|
|||
};
|
||||
}
|
||||
|
||||
export function createConfigureKeybindingAction(commandId: string, when: ContextKeyExpression | undefined = undefined, commandService: ICommandService, keybindingService: IKeybindingService): IAction {
|
||||
export function createConfigureKeybindingAction(commandService: ICommandService, keybindingService: IKeybindingService, commandId: string, when: ContextKeyExpression | undefined = undefined, enabled = true): IAction {
|
||||
return toAction({
|
||||
id: `configureKeybinding/${commandId}`,
|
||||
label: localize('configure keybinding', "Configure Keybinding"),
|
||||
enabled,
|
||||
run() {
|
||||
// Only set the when clause when there is no keybinding
|
||||
// It is possible that the action and the keybinding have different when clauses
|
||||
|
|
Loading…
Reference in a new issue