提交 9a5e8b3a 编写于 作者: J Joao Moreno

fixes #40261

上级 9a34f5ae
...@@ -73,12 +73,18 @@ export class ListService implements IListService { ...@@ -73,12 +73,18 @@ export class ListService implements IListService {
} }
const RawWorkbenchListFocusContextKey = new RawContextKey<boolean>('listFocus', true); const RawWorkbenchListFocusContextKey = new RawContextKey<boolean>('listFocus', true);
export const WorkbenchListSupportsMultiSelectContextKey = new RawContextKey<boolean>('listSupportsMultiselect', true);
export const WorkbenchListFocusContextKey = ContextKeyExpr.and(RawWorkbenchListFocusContextKey, ContextKeyExpr.not(InputFocusedContextKey)); export const WorkbenchListFocusContextKey = ContextKeyExpr.and(RawWorkbenchListFocusContextKey, ContextKeyExpr.not(InputFocusedContextKey));
export type Widget = List<any> | PagedList<any> | ITree; export type Widget = List<any> | PagedList<any> | ITree;
function createScopedContextKeyService(contextKeyService: IContextKeyService, widget: Widget): IContextKeyService { function createScopedContextKeyService(contextKeyService: IContextKeyService, widget: Widget): IContextKeyService {
const result = contextKeyService.createScoped(widget.getHTMLElement()); const result = contextKeyService.createScoped(widget.getHTMLElement());
if (widget instanceof List || widget instanceof PagedList) {
WorkbenchListSupportsMultiSelectContextKey.bindTo(result);
}
RawWorkbenchListFocusContextKey.bindTo(result); RawWorkbenchListFocusContextKey.bindTo(result);
return result; return result;
} }
......
...@@ -19,9 +19,10 @@ import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/edi ...@@ -19,9 +19,10 @@ import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/edi
import URI from 'vs/base/common/uri'; import URI from 'vs/base/common/uri';
import { IEditorOptions, Position as EditorPosition } from 'vs/platform/editor/common/editor'; import { IEditorOptions, Position as EditorPosition } from 'vs/platform/editor/common/editor';
import { openFolderCommand, openFileInNewWindowCommand, openFileFolderInNewWindowCommand, openFolderInNewWindowCommand, openWorkspaceInNewWindowCommand } from 'vs/workbench/browser/actions/workspaceActions'; 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 { PagedList } from 'vs/base/browser/ui/list/listPaging';
import { range } from 'vs/base/common/arrays'; import { range } from 'vs/base/common/arrays';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
// --- List Commands // --- List Commands
...@@ -304,7 +305,7 @@ export function registerCommands(): void { ...@@ -304,7 +305,7 @@ export function registerCommands(): void {
KeybindingsRegistry.registerCommandAndKeybindingRule({ KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'list.selectAll', id: 'list.selectAll',
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
when: WorkbenchListFocusContextKey, when: ContextKeyExpr.and(WorkbenchListFocusContextKey, WorkbenchListSupportsMultiSelectContextKey),
primary: KeyMod.CtrlCmd | KeyCode.KEY_A, primary: KeyMod.CtrlCmd | KeyCode.KEY_A,
handler: (accessor) => { handler: (accessor) => {
const focused = accessor.get(IListService).lastFocusedList; const focused = accessor.get(IListService).lastFocusedList;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册