Fix default tree find modes (#237057)

fix #236770
pull/237173/head
Benjamin Christopher Simmonds 2024-12-29 08:44:19 +01:00 committed by GitHub
parent 1410d77f6f
commit a3261eae42
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 9 deletions

View File

@ -947,7 +947,7 @@ interface IAbstractFindControllerOptions extends IFindWidgetOptions {
showNotFoundMessage?: boolean;
}
interface IFindControllerOptions extends IAbstractFindControllerOptions {
export interface IFindControllerOptions extends IAbstractFindControllerOptions {
defaultFindMode?: TreeFindMode;
defaultFindMatchType?: TreeFindMatchType;
}

View File

@ -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';
@ -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);
@ -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> {
@ -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');