Skip to content

Commit a3261ea

Browse files
authored
Fix default tree find modes (#237057)
fix #236770
1 parent 1410d77 commit a3261ea

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

src/vs/base/browser/ui/tree/abstractTree.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ interface IAbstractFindControllerOptions extends IFindWidgetOptions {
947947
showNotFoundMessage?: boolean;
948948
}
949949

950-
interface IFindControllerOptions extends IAbstractFindControllerOptions {
950+
export interface IFindControllerOptions extends IAbstractFindControllerOptions {
951951
defaultFindMode?: TreeFindMode;
952952
defaultFindMatchType?: TreeFindMatchType;
953953
}

src/vs/base/browser/ui/tree/asyncDataTree.ts

+19-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { IDragAndDropData } from '../../dnd.js';
77
import { IIdentityProvider, IKeyboardNavigationLabelProvider, IListDragAndDrop, IListDragOverReaction, IListVirtualDelegate } from '../list/list.js';
88
import { ElementsDragAndDropData, ListViewTargetSector } from '../list/listView.js';
99
import { IListStyles } from '../list/listWidget.js';
10-
import { ComposedTreeDelegate, TreeFindMode as TreeFindMode, IAbstractTreeOptions, IAbstractTreeOptionsUpdate, TreeFindMatchType, AbstractTreePart, LabelFuzzyScore, FindFilter, FindController, ITreeFindToggleChangeEvent } from './abstractTree.js';
10+
import { ComposedTreeDelegate, TreeFindMode as TreeFindMode, IAbstractTreeOptions, IAbstractTreeOptionsUpdate, TreeFindMatchType, AbstractTreePart, LabelFuzzyScore, FindFilter, FindController, ITreeFindToggleChangeEvent, IFindControllerOptions } from './abstractTree.js';
1111
import { ICompressedTreeElement, ICompressedTreeNode } from './compressedObjectTreeModel.js';
1212
import { getVisibleState, isFilterResult } from './indexTreeModel.js';
1313
import { CompressibleObjectTree, ICompressibleKeyboardNavigationLabelProvider, ICompressibleObjectTreeOptions, ICompressibleTreeRenderer, IObjectTreeOptions, IObjectTreeSetChildrenOptions, ObjectTree } from './objectTree.js';
@@ -629,7 +629,12 @@ export class AsyncDataTree<TInput, T, TFilterData = void> implements IDisposable
629629
this.tree.onDidChangeCollapseState(this._onDidChangeCollapseState, this, this.disposables);
630630

631631
if (asyncFindEnabled) {
632-
const findOptions = { styles: options.findWidgetStyles, showNotFoundMessage: options.showNotFoundMessage };
632+
const findOptions: IFindControllerOptions = {
633+
styles: options.findWidgetStyles,
634+
showNotFoundMessage: options.showNotFoundMessage,
635+
defaultFindMatchType: options.defaultFindMatchType,
636+
defaultFindMode: options.defaultFindMode,
637+
};
633638
this.findController = this.disposables.add(new AsyncFindController(this.tree, options.findProvider!, findFilter!, this.tree.options.contextViewProvider!, findOptions));
634639

635640
this.focusNavigationFilter = node => this.findController!.shouldFocusWhenNavigating(node);
@@ -657,8 +662,18 @@ export class AsyncDataTree<TInput, T, TFilterData = void> implements IDisposable
657662
return new ObjectTree(user, container, objectTreeDelegate, objectTreeRenderers, objectTreeOptions);
658663
}
659664

660-
updateOptions(options: IAsyncDataTreeOptionsUpdate = {}): void {
661-
this.tree.updateOptions(options);
665+
updateOptions(optionsUpdate: IAsyncDataTreeOptionsUpdate = {}): void {
666+
if (this.findController) {
667+
if (optionsUpdate.defaultFindMode !== undefined) {
668+
this.findController.mode = optionsUpdate.defaultFindMode;
669+
}
670+
671+
if (optionsUpdate.defaultFindMatchType !== undefined) {
672+
this.findController.matchType = optionsUpdate.defaultFindMatchType;
673+
}
674+
}
675+
676+
this.tree.updateOptions(optionsUpdate);
662677
}
663678

664679
get options(): IAsyncDataTreeOptions<T, TFilterData> {
@@ -1513,10 +1528,6 @@ export class CompressibleAsyncDataTree<TInput, T, TFilterData = void> extends As
15131528
};
15141529
}
15151530

1516-
override updateOptions(options: ICompressibleAsyncDataTreeOptionsUpdate = {}): void {
1517-
this.tree.updateOptions(options);
1518-
}
1519-
15201531
override getViewState(): IAsyncDataTreeViewState {
15211532
if (!this.identityProvider) {
15221533
throw new TreeError(this.user, 'Can\'t get tree view state without an identity provider');

0 commit comments

Comments
 (0)