From 3982a3996e2388622ef41c0c8c9e66053887858d Mon Sep 17 00:00:00 2001 From: Connor Peet Date: Thu, 2 Nov 2023 17:47:54 -0700 Subject: [PATCH] testing: fix performance when unloading a bunch of tests (#197294) We were unnecessary recomputing the state for child items, when we only needed to do so for the removed root Fixes #193240 --- .../browser/explorerProjections/treeProjection.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/vs/workbench/contrib/testing/browser/explorerProjections/treeProjection.ts b/src/vs/workbench/contrib/testing/browser/explorerProjections/treeProjection.ts index 3e67da4150b87..2e0374be9cd0f 100644 --- a/src/vs/workbench/contrib/testing/browser/explorerProjections/treeProjection.ts +++ b/src/vs/workbench/contrib/testing/browser/explorerProjections/treeProjection.ts @@ -224,8 +224,9 @@ export class TreeProjection extends Disposable implements ITestTreeProjection { } // The first element will cause the root to be hidden - const affectsRootElement = toRemove.depth === 1 && toRemove.parent?.children.size === 1; - this.changedParents.add(affectsRootElement ? null : toRemove.parent); + const parent = toRemove.parent; + const affectsRootElement = toRemove.depth === 1 && parent?.children.size === 1; + this.changedParents.add(affectsRootElement ? null : parent); const queue: Iterable[] = [[toRemove]]; while (queue.length) { @@ -235,6 +236,10 @@ export class TreeProjection extends Disposable implements ITestTreeProjection { } } } + + if (parent instanceof TreeTestItemElement) { + refreshComputedState(computedStateAccessor, parent, undefined, !!parent.duration).forEach(i => i.fireChange()); + } } } } @@ -290,10 +295,6 @@ export class TreeProjection extends Disposable implements ITestTreeProjection { const parent = treeElement.parent; parent?.children.delete(treeElement); this.items.delete(treeElement.test.item.extId); - if (parent instanceof TreeTestItemElement) { - refreshComputedState(computedStateAccessor, parent, undefined, !!treeElement.duration).forEach(i => i.fireChange()); - } - return treeElement.children; }