From 9a5e8b3ae515217244071ec33eaca26903a71269 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Fri, 15 Dec 2017 08:27:39 +0100 Subject: [PATCH] fixes #40261 --- src/vs/platform/list/browser/listService.ts | 6 ++++++ src/vs/workbench/electron-browser/commands.ts | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/vs/platform/list/browser/listService.ts b/src/vs/platform/list/browser/listService.ts index b4d344e30ac..5ae623175f4 100644 --- a/src/vs/platform/list/browser/listService.ts +++ b/src/vs/platform/list/browser/listService.ts @@ -73,12 +73,18 @@ export class ListService implements IListService { } const RawWorkbenchListFocusContextKey = new RawContextKey('listFocus', true); +export const WorkbenchListSupportsMultiSelectContextKey = new RawContextKey('listSupportsMultiselect', true); export const WorkbenchListFocusContextKey = ContextKeyExpr.and(RawWorkbenchListFocusContextKey, ContextKeyExpr.not(InputFocusedContextKey)); export type Widget = List | PagedList | ITree; function createScopedContextKeyService(contextKeyService: IContextKeyService, widget: Widget): IContextKeyService { const result = contextKeyService.createScoped(widget.getHTMLElement()); + + if (widget instanceof List || widget instanceof PagedList) { + WorkbenchListSupportsMultiSelectContextKey.bindTo(result); + } + RawWorkbenchListFocusContextKey.bindTo(result); return result; } diff --git a/src/vs/workbench/electron-browser/commands.ts b/src/vs/workbench/electron-browser/commands.ts index b7f991b44e9..571d2f562fd 100644 --- a/src/vs/workbench/electron-browser/commands.ts +++ b/src/vs/workbench/electron-browser/commands.ts @@ -19,9 +19,10 @@ import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/edi import URI from 'vs/base/common/uri'; import { IEditorOptions, Position as EditorPosition } from 'vs/platform/editor/common/editor'; import { openFolderCommand, openFileInNewWindowCommand, openFileFolderInNewWindowCommand, openFolderInNewWindowCommand, openWorkspaceInNewWindowCommand } from 'vs/workbench/browser/actions/workspaceActions'; -import { WorkbenchListFocusContextKey, IListService } from 'vs/platform/list/browser/listService'; +import { WorkbenchListFocusContextKey, IListService, WorkbenchListSupportsMultiSelectContextKey } from 'vs/platform/list/browser/listService'; import { PagedList } from 'vs/base/browser/ui/list/listPaging'; import { range } from 'vs/base/common/arrays'; +import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; // --- List Commands @@ -304,7 +305,7 @@ export function registerCommands(): void { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'list.selectAll', weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), - when: WorkbenchListFocusContextKey, + when: ContextKeyExpr.and(WorkbenchListFocusContextKey, WorkbenchListSupportsMultiSelectContextKey), primary: KeyMod.CtrlCmd | KeyCode.KEY_A, handler: (accessor) => { const focused = accessor.get(IListService).lastFocusedList; -- GitLab