Skip to content

Commit 24a1737

Browse files
committed
Async find
1 parent 47a8de0 commit 24a1737

File tree

2 files changed

+396
-22
lines changed

2 files changed

+396
-22
lines changed

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

+9-5
Original file line numberDiff line numberDiff line change
@@ -2539,6 +2539,7 @@ export abstract class AbstractTree<T, TFilterData, TRef> implements IDisposable
25392539
private anchor: Trait<T>;
25402540
private eventBufferer = new EventBufferer();
25412541
private findController?: FindController<T, TFilterData>;
2542+
private findFilter?: FindFilter<T>;
25422543
readonly onDidChangeFindOpenState: Event<boolean> = Event.None;
25432544
onDidChangeStickyScrollFocused: Event<boolean> = Event.None;
25442545
private focusNavigationFilter: ((node: ITreeNode<T, TFilterData>) => boolean) | undefined;
@@ -2605,11 +2606,10 @@ export abstract class AbstractTree<T, TFilterData, TRef> implements IDisposable
26052606
renderers: ITreeRenderer<T, TFilterData, any>[],
26062607
private _options: IAbstractTreeOptions<T, TFilterData> = {}
26072608
) {
2608-
let filter: FindFilter<T> | undefined;
26092609
if (_options.keyboardNavigationLabelProvider) {
2610-
filter = new FindFilter(this, _options.keyboardNavigationLabelProvider, _options.filter as any as ITreeFilter<T, FuzzyScore>);
2611-
_options = { ..._options, filter: filter as ITreeFilter<T, TFilterData> }; // TODO need typescript help here
2612-
this.disposables.add(filter);
2610+
this.findFilter = new FindFilter(this, _options.keyboardNavigationLabelProvider, _options.filter as any as ITreeFilter<T, FuzzyScore>);
2611+
_options = { ..._options, filter: this.findFilter as ITreeFilter<T, TFilterData> }; // TODO need typescript help here
2612+
this.disposables.add(this.findFilter);
26132613
}
26142614

26152615
this.model = this.createModel(_user, _options);
@@ -2646,7 +2646,7 @@ export abstract class AbstractTree<T, TFilterData, TRef> implements IDisposable
26462646
defaultFindMode: _options.defaultFindMode,
26472647
defaultFindMatchType: _options.defaultFindMatchType,
26482648
};
2649-
this.findController = this.disposables.add(new FindController(this, filter!, _options.contextViewProvider, findOptions));
2649+
this.findController = this.disposables.add(new FindController(this, this.findFilter!, _options.contextViewProvider, findOptions));
26502650
this.focusNavigationFilter = node => this.findController!.shouldAllowFocus(node);
26512651
this.onDidChangeFindOpenState = this.findController.onDidChangeOpenState;
26522652
this.onDidChangeFindMode = this.findController.onDidChangeMode;
@@ -3162,6 +3162,10 @@ export abstract class AbstractTree<T, TFilterData, TRef> implements IDisposable
31623162

31633163
protected abstract createModel(user: string, options: IAbstractTreeOptions<T, TFilterData>): ITreeModel<T, TFilterData, TRef>;
31643164

3165+
createNewModel(options: IAbstractTreeOptions<T, TFilterData> = {}): ITreeModel<T, TFilterData, TRef> {
3166+
return this.createModel(this._user, { ...this._options, filter: this.findFilter as ITreeFilter<T, TFilterData> | undefined, ...options });
3167+
}
3168+
31653169
private readonly modelDisposables = new DisposableStore();
31663170
private setupModel(model: ITreeModel<T, TFilterData, TRef>) {
31673171
this.modelDisposables.clear();

0 commit comments

Comments
 (0)