440
}));
441
};
443
>
this._onDidChange = new DebounceEmitter({
444
>
// start/stop context key listener
445
>
onWillAddFirstListener: startLazyListener,
446
>
onDidRemoveLastListener: lazyListener.clear.bind(lazyListener),
447
>
delay: options.eventDebounceDelay,
448
>
merge
449
>
});
450
>
this.onDidChange = this._onDidChange.event;
451
>
}
452
453
getActions(options?: IMenuActionOptions | undefined): [string, (MenuItemAction | SubmenuItemAction)[]][] {
454
>
return this._menuInfo.createActionGroups(options);
menuService.ts
455
>
}
456
457
dispose(): void {
459
>
this._onDidChange.dispose();
460
>
}
461
}
462
463
>
function createMenuHide(menu: MenuId, command: ICommandAction | ISubmenuItem, states: PersistedMenuHideState): IMenuItemHide {
menuService.ts
464
>
465
>
const id = isISubmenuItem(command) ? command.submenu.id : command.id;
466
>
const title = typeof command.title === 'string' ? command.title : command.title.value;
467
>
468
>
const hide = toAction({
469
>
id: `hide/${menu.id}/${id}`,
470
>
label: localize('hide.label', 'Hide \'{0}\'', title),
471
>
run() { states.updateHidden(menu, id, true); }
472
>
});
473
>
474
>
const toggle = toAction({
475
>
id: `toggle/${menu.id}/${id}`,
476
>
label: title,
477
>
get checked() { return !states.isHidden(menu, id); },
478
>
run() { states.updateHidden(menu, id, !!this.checked); }
479
>
});
480
>
481
>
return {
482
>
hide,
483
>
toggle,
484
>
get isHidden() { return !toggle.checked; },
485
>
};
486
>
}
487
488
export function createConfigureKeybindingAction(commandService: ICommandService, keybindingService: IKeybindingService, commandId: string, when: ContextKeyExpression | undefined = undefined, enabled = true): IAction {
490
>
id: `configureKeybinding/${commandId}`,
491
>
label: localize('configure keybinding', "Configure Keybinding"),
492
>
enabled,
493
>
run() {
494
// Only set the when clause when there is no keybinding
495
// It is possible that the action and the keybinding have different when clauses