in src/tree.ts [46:113]
async setInput(input: SymbolTreeInput<unknown>) {
if (!await isValidRequestPosition(input.location.uri, input.location.range.start)) {
this.clearInput();
return;
}
this._ctxInputSource.set(input.contextValue);
this._ctxIsActive.set(true);
this._ctxHasResult.set(true);
vscode.commands.executeCommand(`${this.viewId}.focus`);
const newInputKind = !this._input || Object.getPrototypeOf(this._input) !== Object.getPrototypeOf(input);
this._input = input;
this._sessionDisposable?.dispose();
this._tree.title = input.title;
this._tree.message = newInputKind ? undefined : this._tree.message;
const modelPromise = Promise.resolve(input.resolve());
// set promise to tree data provider to trigger tree loading UI
this._provider.update(modelPromise.then(model => model?.provider ?? this._history));
const model = await modelPromise;
if (this._input !== input) {
return;
}
if (!model) {
this.clearInput();
return;
}
this._history.add(input);
this._tree.message = model.message;
// navigation
this._navigation.update(model.navigation);
// reveal & select
const selection = model.navigation?.nearest(input.location.uri, input.location.range.start);
if (selection && this._tree.visible) {
await this._tree.reveal(selection, { select: true, focus: true, expand: true });
}
const disposables: vscode.Disposable[] = [];
// editor highlights
let highlights: EditorHighlights<unknown> | undefined;
if (model.highlights) {
highlights = new EditorHighlights(this._tree, model.highlights);
disposables.push(highlights);
}
// listener
if (model.provider.onDidChangeTreeData) {
disposables.push(model.provider.onDidChangeTreeData(() => {
this._tree.title = input.title;
this._tree.message = model.message;
highlights?.update();
}));
}
if (typeof model.dispose === 'function') {
disposables.push(new vscode.Disposable(() => model.dispose!()));
}
this._sessionDisposable = vscode.Disposable.from(...disposables);
}