Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update list find context key #156903

Merged
merged 1 commit into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/vs/platform/list/browser/listService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ export const WorkbenchListHasSelectionOrFocus = new RawContextKey<boolean>('list
export const WorkbenchListDoubleSelection = new RawContextKey<boolean>('listDoubleSelection', false);
export const WorkbenchListMultiSelection = new RawContextKey<boolean>('listMultiSelection', false);
export const WorkbenchListSelectionNavigation = new RawContextKey<boolean>('listSelectionNavigation', false);
export const WorkbenchListSupportsFind = new RawContextKey<boolean>('listSupportsFind', true);
export const WorkbenchTreeElementCanCollapse = new RawContextKey<boolean>('treeElementCanCollapse', false);
export const WorkbenchTreeElementHasParent = new RawContextKey<boolean>('treeElementHasParent', false);
export const WorkbenchTreeElementCanExpand = new RawContextKey<boolean>('treeElementCanExpand', false);
export const WorkbenchTreeElementHasChild = new RawContextKey<boolean>('treeElementHasChild', false);
export const WorkbenchTreeFindOpen = new RawContextKey<boolean>('treeFindOpen', false);
export const WorkbenchTreeSupportsFind = new RawContextKey<boolean>('treeSupportsFind', true);
const WorkbenchListTypeNavigationModeKey = 'listTypeNavigationMode';

/**
Expand Down Expand Up @@ -1136,6 +1136,7 @@ class WorkbenchTreeInternals<TInput, T, TFilterData> {

readonly contextKeyService: IContextKeyService;
private listSupportsMultiSelect: IContextKey<boolean>;
private listSupportFindWidget: IContextKey<boolean>;
private hasSelectionOrFocus: IContextKey<boolean>;
private hasDoubleSelection: IContextKey<boolean>;
private hasMultiSelection: IContextKey<boolean>;
Expand All @@ -1144,7 +1145,6 @@ class WorkbenchTreeInternals<TInput, T, TFilterData> {
private treeElementCanExpand: IContextKey<boolean>;
private treeElementHasChild: IContextKey<boolean>;
private treeFindOpen: IContextKey<boolean>;
private treeSupportFindWidget: IContextKey<boolean>;
private _useAltAsMultipleSelectionModifier: boolean;
private disposables: IDisposable[] = [];
private styler: IDisposable | undefined;
Expand All @@ -1170,6 +1170,9 @@ class WorkbenchTreeInternals<TInput, T, TFilterData> {
const listSelectionNavigation = WorkbenchListSelectionNavigation.bindTo(this.contextKeyService);
listSelectionNavigation.set(Boolean(options.selectionNavigation));

this.listSupportFindWidget = WorkbenchListSupportsFind.bindTo(this.contextKeyService);
this.listSupportFindWidget.set(options.findWidgetEnabled ?? true);

this.hasSelectionOrFocus = WorkbenchListHasSelectionOrFocus.bindTo(this.contextKeyService);
this.hasDoubleSelection = WorkbenchListDoubleSelection.bindTo(this.contextKeyService);
this.hasMultiSelection = WorkbenchListMultiSelection.bindTo(this.contextKeyService);
Expand All @@ -1180,8 +1183,6 @@ class WorkbenchTreeInternals<TInput, T, TFilterData> {
this.treeElementHasChild = WorkbenchTreeElementHasChild.bindTo(this.contextKeyService);

this.treeFindOpen = WorkbenchTreeFindOpen.bindTo(this.contextKeyService);
this.treeSupportFindWidget = WorkbenchTreeSupportsFind.bindTo(this.contextKeyService);
this.treeSupportFindWidget.set(options.findWidgetEnabled ?? true);

this._useAltAsMultipleSelectionModifier = useAltAsMultipleSelectionModifier(configurationService);

Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/browser/actions/listCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { List } from 'vs/base/browser/ui/list/listWidget';
import { WorkbenchListFocusContextKey, IListService, WorkbenchListSupportsMultiSelectContextKey, ListWidget, WorkbenchListHasSelectionOrFocus, getSelectionKeyboardEvent, WorkbenchListWidget, WorkbenchListSelectionNavigation, WorkbenchTreeElementCanCollapse, WorkbenchTreeElementHasParent, WorkbenchTreeElementHasChild, WorkbenchTreeElementCanExpand, RawWorkbenchListFocusContextKey, WorkbenchTreeFindOpen, WorkbenchTreeSupportsFind } from 'vs/platform/list/browser/listService';
import { WorkbenchListFocusContextKey, IListService, WorkbenchListSupportsMultiSelectContextKey, ListWidget, WorkbenchListHasSelectionOrFocus, getSelectionKeyboardEvent, WorkbenchListWidget, WorkbenchListSelectionNavigation, WorkbenchTreeElementCanCollapse, WorkbenchTreeElementHasParent, WorkbenchTreeElementHasChild, WorkbenchTreeElementCanExpand, RawWorkbenchListFocusContextKey, WorkbenchTreeFindOpen, WorkbenchListSupportsFind } from 'vs/platform/list/browser/listService';
import { PagedList } from 'vs/base/browser/ui/list/listPaging';
import { equals, range } from 'vs/base/common/arrays';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
Expand Down Expand Up @@ -634,7 +634,7 @@ CommandsRegistry.registerCommandAlias('list.toggleFilterOnType', 'list.toggleFin
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'list.find',
weight: KeybindingWeight.WorkbenchContrib,
when: ContextKeyExpr.and(RawWorkbenchListFocusContextKey, WorkbenchTreeSupportsFind),
when: ContextKeyExpr.and(RawWorkbenchListFocusContextKey, WorkbenchListSupportsFind),
primary: KeyMod.CtrlCmd | KeyCode.KeyF,
secondary: [KeyCode.F3],
handler: (accessor) => {
Expand Down