From e3e7cca3a6c5a54f2b4f9be34a8204e7cfe2ffa7 Mon Sep 17 00:00:00 2001 From: isidor Date: Fri, 23 Sep 2016 16:11:45 +0200 Subject: [PATCH] activitybar: keybinding label for toggle panel --- .../parts/activitybar/activitybarPart.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/vs/workbench/browser/parts/activitybar/activitybarPart.ts b/src/vs/workbench/browser/parts/activitybar/activitybarPart.ts index 8af41a647d2..25fbcfe09be 100644 --- a/src/vs/workbench/browser/parts/activitybar/activitybarPart.ts +++ b/src/vs/workbench/browser/parts/activitybar/activitybarPart.ts @@ -149,7 +149,7 @@ export class ActivitybarPart extends Part implements IActivityService { const allPanels = (Registry.as(PanelExtensions.Panels)).getPanels(); this.showPanelAction = this.instantiationService.createInstance(TogglePanelAction, TogglePanelAction.ID, TogglePanelAction.LABEL); - this.activityActionItems[this.showPanelAction.id] = new ActivityActionItem(this.showPanelAction); + this.activityActionItems[this.showPanelAction.id] = new ActivityActionItem(this.showPanelAction, TogglePanelAction.LABEL, this.getKeybindingLabel(TogglePanelAction.ID)); this.panelActions = allPanels.sort((p1, p2) => p1.order - p2.order).map(panel => this.toAction(panel)); // Add both viewlet and panel actions to the switcher @@ -172,13 +172,7 @@ export class ActivitybarPart extends Part implements IActivityService { const action = composite instanceof ViewletDescriptor ? this.instantiationService.createInstance(ViewletActivityAction, composite.id + '.activity-bar-action', composite) : this.instantiationService.createInstance(PanelActivityAction, composite.id + '.activity-bar-action', composite); - let keybinding: string = null; - const keys = this.keybindingService.lookupKeybindings(composite.id).map(k => this.keybindingService.getLabelFor(k)); - if (keys && keys.length) { - keybinding = keys[0]; - } - - this.activityActionItems[action.id] = new ActivityActionItem(action, composite.name, keybinding); + this.activityActionItems[action.id] = new ActivityActionItem(action, composite.name, this.getKeybindingLabel(composite.id)); this.compositeIdToActions[composite.id] = action; // Mark active viewlet and panel action as active @@ -189,6 +183,15 @@ export class ActivitybarPart extends Part implements IActivityService { return action; }; + private getKeybindingLabel(id: string): string { + const keys = this.keybindingService.lookupKeybindings(id).map(k => this.keybindingService.getLabelFor(k)); + if (keys && keys.length) { + return keys[0]; + } + + return null; + } + public dispose(): void { if (this.viewletSwitcherBar) { this.viewletSwitcherBar.dispose(); -- GitLab