Fix tree item order when reveal is the cause of getChildren (#200022)

Fixes #191511
This commit is contained in:
Alex Ross 2023-12-05 11:11:58 +00:00 committed by GitHub
parent 1466cbfcdf
commit 95147456e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -658,14 +658,17 @@ class ExtHostTreeView<T> extends Disposable {
return undefined;
}
const items = await Promise.all(coalesce(elements || []).map(async element => {
const item = await this.dataProvider.getTreeItem(element);
return item && !cts.token.isCancellationRequested ? this.createAndRegisterTreeNode(element, item, parentNode) : null;
const coalescedElements = coalesce(elements || []);
const treeItems = await Promise.all(coalesce(coalescedElements).map(element => {
return this.dataProvider.getTreeItem(element);
}));
if (cts.token.isCancellationRequested) {
return undefined;
}
// createAndRegisterTreeNodes adds the nodes to a cache. This must be done sync so that they get added in the correct order.
const items = treeItems.map((item, index) => item ? this.createAndRegisterTreeNode(coalescedElements[index], item, parentNode) : null);
return coalesce(items);
} finally {
cts.dispose();