API proposal for revealing tree view when no elements

Fixes #90005
This commit is contained in:
Alex Ross
2020-11-06 14:46:46 +01:00
parent ce4fb6e323
commit e95c40c1e4
4 changed files with 19 additions and 10 deletions

View File

@@ -293,7 +293,7 @@ class ExtHostTreeView<T> extends Disposable {
return this.elements.get(treeItemHandle);
}
reveal(element: T, options?: IRevealOptions): Promise<void> {
reveal(element: T | undefined, options?: IRevealOptions): Promise<void> {
options = options ? options : { select: true, focus: false };
const select = isUndefinedOrNull(options.select) ? true : options.select;
const focus = isUndefinedOrNull(options.focus) ? false : options.focus;
@@ -302,10 +302,15 @@ class ExtHostTreeView<T> extends Disposable {
if (typeof this.dataProvider.getParent !== 'function') {
return Promise.reject(new Error(`Required registered TreeDataProvider to implement 'getParent' method to access 'reveal' method`));
}
return this.refreshPromise
.then(() => this.resolveUnknownParentChain(element))
.then(parentChain => this.resolveTreeNode(element, parentChain[parentChain.length - 1])
.then(treeNode => this.proxy.$reveal(this.viewId, treeNode.item, parentChain.map(p => p.item), { select, focus, expand })), error => this.logService.error(error));
if (element) {
return this.refreshPromise
.then(() => this.resolveUnknownParentChain(element))
.then(parentChain => this.resolveTreeNode(element, parentChain[parentChain.length - 1])
.then(treeNode => this.proxy.$reveal(this.viewId, { item: treeNode.item, parentChain: parentChain.map(p => p.item) }, { select, focus, expand })), error => this.logService.error(error));
} else {
return this.proxy.$reveal(this.viewId, undefined, { select, focus, expand });
}
}
private _message: string = '';