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; return undefined;
} }
const items = await Promise.all(coalesce(elements || []).map(async element => { const coalescedElements = coalesce(elements || []);
const item = await this.dataProvider.getTreeItem(element); const treeItems = await Promise.all(coalesce(coalescedElements).map(element => {
return item && !cts.token.isCancellationRequested ? this.createAndRegisterTreeNode(element, item, parentNode) : null; return this.dataProvider.getTreeItem(element);
})); }));
if (cts.token.isCancellationRequested) { if (cts.token.isCancellationRequested) {
return undefined; 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); return coalesce(items);
} finally { } finally {
cts.dispose(); cts.dispose();