Skip to content

Commit

Permalink
Fix default tree find modes (#237057)
Browse files Browse the repository at this point in the history
  • Loading branch information
benibenj authored Dec 29, 2024
1 parent 1410d77 commit a3261ea
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/vs/base/browser/ui/tree/abstractTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ interface IAbstractFindControllerOptions extends IFindWidgetOptions {
showNotFoundMessage?: boolean;
}

interface IFindControllerOptions extends IAbstractFindControllerOptions {
export interface IFindControllerOptions extends IAbstractFindControllerOptions {
defaultFindMode?: TreeFindMode;
defaultFindMatchType?: TreeFindMatchType;
}
Expand Down
27 changes: 19 additions & 8 deletions src/vs/base/browser/ui/tree/asyncDataTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { IDragAndDropData } from '../../dnd.js';
import { IIdentityProvider, IKeyboardNavigationLabelProvider, IListDragAndDrop, IListDragOverReaction, IListVirtualDelegate } from '../list/list.js';
import { ElementsDragAndDropData, ListViewTargetSector } from '../list/listView.js';
import { IListStyles } from '../list/listWidget.js';
import { ComposedTreeDelegate, TreeFindMode as TreeFindMode, IAbstractTreeOptions, IAbstractTreeOptionsUpdate, TreeFindMatchType, AbstractTreePart, LabelFuzzyScore, FindFilter, FindController, ITreeFindToggleChangeEvent } from './abstractTree.js';
import { ComposedTreeDelegate, TreeFindMode as TreeFindMode, IAbstractTreeOptions, IAbstractTreeOptionsUpdate, TreeFindMatchType, AbstractTreePart, LabelFuzzyScore, FindFilter, FindController, ITreeFindToggleChangeEvent, IFindControllerOptions } from './abstractTree.js';
import { ICompressedTreeElement, ICompressedTreeNode } from './compressedObjectTreeModel.js';
import { getVisibleState, isFilterResult } from './indexTreeModel.js';
import { CompressibleObjectTree, ICompressibleKeyboardNavigationLabelProvider, ICompressibleObjectTreeOptions, ICompressibleTreeRenderer, IObjectTreeOptions, IObjectTreeSetChildrenOptions, ObjectTree } from './objectTree.js';
Expand Down Expand Up @@ -629,7 +629,12 @@ export class AsyncDataTree<TInput, T, TFilterData = void> implements IDisposable
this.tree.onDidChangeCollapseState(this._onDidChangeCollapseState, this, this.disposables);

if (asyncFindEnabled) {
const findOptions = { styles: options.findWidgetStyles, showNotFoundMessage: options.showNotFoundMessage };
const findOptions: IFindControllerOptions = {
styles: options.findWidgetStyles,
showNotFoundMessage: options.showNotFoundMessage,
defaultFindMatchType: options.defaultFindMatchType,
defaultFindMode: options.defaultFindMode,
};
this.findController = this.disposables.add(new AsyncFindController(this.tree, options.findProvider!, findFilter!, this.tree.options.contextViewProvider!, findOptions));

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

updateOptions(options: IAsyncDataTreeOptionsUpdate = {}): void {
this.tree.updateOptions(options);
updateOptions(optionsUpdate: IAsyncDataTreeOptionsUpdate = {}): void {
if (this.findController) {
if (optionsUpdate.defaultFindMode !== undefined) {
this.findController.mode = optionsUpdate.defaultFindMode;
}

if (optionsUpdate.defaultFindMatchType !== undefined) {
this.findController.matchType = optionsUpdate.defaultFindMatchType;
}
}

this.tree.updateOptions(optionsUpdate);
}

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

override updateOptions(options: ICompressibleAsyncDataTreeOptionsUpdate = {}): void {
this.tree.updateOptions(options);
}

override getViewState(): IAsyncDataTreeViewState {
if (!this.identityProvider) {
throw new TreeError(this.user, 'Can\'t get tree view state without an identity provider');
Expand Down

0 comments on commit a3261ea

Please sign in to comment.