From a3d05a0fee3149ebe368f40a7cecc0328afeb5d0 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Sat, 19 Nov 2016 13:10:23 +0100 Subject: [PATCH] show missing keybindings (part of #15742) --- .../parts/files/browser/fileActions.contribution.ts | 2 +- src/vs/workbench/parts/files/browser/fileActions.ts | 2 +- .../workbench/parts/files/browser/views/explorerViewer.ts | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/vs/workbench/parts/files/browser/fileActions.contribution.ts b/src/vs/workbench/parts/files/browser/fileActions.contribution.ts index c966dc136d2..396a8a96119 100644 --- a/src/vs/workbench/parts/files/browser/fileActions.contribution.ts +++ b/src/vs/workbench/parts/files/browser/fileActions.contribution.ts @@ -123,7 +123,7 @@ class FilesViewerActionContributor extends ActionBarContributor { if (context && context.element instanceof FileStat) { // Any other item with keybinding - const keybinding = keybindingForAction(action.id); + const keybinding = keybindingForAction(action.id, this.keybindingService); if (keybinding) { return new ActionItem(context, action, { label: true, keybinding: this.keybindingService.getLabelFor(keybinding) }); } diff --git a/src/vs/workbench/parts/files/browser/fileActions.ts b/src/vs/workbench/parts/files/browser/fileActions.ts index c654aba4d43..2463664c3d2 100644 --- a/src/vs/workbench/parts/files/browser/fileActions.ts +++ b/src/vs/workbench/parts/files/browser/fileActions.ts @@ -1859,7 +1859,7 @@ export class RefreshExplorerView extends Action { } } -export function keybindingForAction(id: string, keybindingService?: IKeybindingService): Keybinding { +export function keybindingForAction(id: string, keybindingService: IKeybindingService): Keybinding { switch (id) { case GlobalNewUntitledFileAction.ID: return new Keybinding(KeyMod.CtrlCmd | KeyCode.KEY_N); diff --git a/src/vs/workbench/parts/files/browser/views/explorerViewer.ts b/src/vs/workbench/parts/files/browser/views/explorerViewer.ts index 6f1bb39273f..de3bd799aeb 100644 --- a/src/vs/workbench/parts/files/browser/views/explorerViewer.ts +++ b/src/vs/workbench/parts/files/browser/views/explorerViewer.ts @@ -34,6 +34,7 @@ import { ClickBehavior, DefaultController } from 'vs/base/parts/tree/browser/tre import { ActionsRenderer } from 'vs/base/parts/tree/browser/actionsRenderer'; import { FileStat, NewStatPlaceholder } from 'vs/workbench/parts/files/common/explorerViewModel'; import { DragMouseEvent, IMouseEvent } from 'vs/base/browser/mouseEvent'; +import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IPartService } from 'vs/workbench/services/part/common/partService'; import { IWorkspace, IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; @@ -389,7 +390,8 @@ export class FileController extends DefaultController { @ITelemetryService private telemetryService: ITelemetryService, @IWorkspaceContextService contextService: IWorkspaceContextService, @IMenuService menuService: IMenuService, - @IContextKeyService contextKeyService: IContextKeyService + @IContextKeyService contextKeyService: IContextKeyService, + @IKeybindingService private keybindingService: IKeybindingService ) { super({ clickBehavior: ClickBehavior.ON_MOUSE_UP /* do not change to not break DND */ }); @@ -510,7 +512,7 @@ export class FileController extends DefaultController { }); }, getActionItem: this.state.actionProvider.getActionItem.bind(this.state.actionProvider, tree, stat), - getKeyBinding: (a): Keybinding => keybindingForAction(a.id), + getKeyBinding: (a): Keybinding => keybindingForAction(a.id, this.keybindingService), getActionsContext: (event) => { return { viewletState: this.state, -- GitLab