Skip to content

Commit de68ea3

Browse files
authored
testing: fix state not updating when failing peek opens (#186802)
* testing: improve performance when ending test with large number of results Takes `markTaskComplete` 11,200ms to 70ms when running a 10k test suite, by maintaining a count of computed states for children and avoiding refreshing nodes unnecessarily. For microsoft/vscode-python#21507 * testing: fix state not updating when failing peek opens Fixes #186376
1 parent 61718f8 commit de68ea3

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

src/vs/base/browser/ui/tree/compressedObjectTreeModel.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export class CompressedObjectTreeModel<T extends NonNullable<any>, TFilterData e
146146
children: Iterable<ICompressedTreeElement<T>> = Iterable.empty(),
147147
options: IObjectTreeModelSetChildrenOptions<T, TFilterData>,
148148
): void {
149-
// Diffs must be deem, since the compression can affect nested elements.
149+
// Diffs must be deep, since the compression can affect nested elements.
150150
// @see https://github.com/microsoft/vscode/pull/114237#issuecomment-759425034
151151

152152
const diffIdentityProvider = options.diffIdentityProvider && wrapIdentityProvider(options.diffIdentityProvider);

src/vs/workbench/contrib/testing/browser/testingOutputPeek.ts

+17-6
Original file line numberDiff line numberDiff line change
@@ -1670,7 +1670,7 @@ class OutputPeekTree extends Disposable {
16701670
taskChildrenToUpdate.clear();
16711671
}, 300));
16721672

1673-
const handleNewResults = (result: LiveTestResult) => {
1673+
const attachToResults = (result: LiveTestResult) => {
16741674
const resultNode = cc.get(result)! as TestResultElement;
16751675
const disposable = new DisposableStore();
16761676
disposable.add(result.onNewTask(() => {
@@ -1713,7 +1713,7 @@ class OutputPeekTree extends Disposable {
17131713
disposable.dispose();
17141714
}));
17151715

1716-
this.tree.expand(resultNode, true);
1716+
return resultNode;
17171717
};
17181718

17191719
this._register(results.onResultsChanged(e => {
@@ -1737,7 +1737,7 @@ class OutputPeekTree extends Disposable {
17371737
this.tree.collapse(child.element, false);
17381738
}
17391739

1740-
handleNewResults(e.started);
1740+
this.tree.expand(attachToResults(e.started), true);
17411741
}
17421742
}));
17431743

@@ -1749,7 +1749,7 @@ class OutputPeekTree extends Disposable {
17491749
}
17501750
};
17511751

1752-
this._register(onDidReveal(({ subject, preserveFocus = false }) => {
1752+
this._register(onDidReveal(async ({ subject, preserveFocus = false }) => {
17531753
if (subject instanceof TaskSubject) {
17541754
const resultItem = this.tree.getNode(null).children.find(c => (c.element as TestResultElement)?.id === subject.resultId);
17551755
if (resultItem) {
@@ -1798,6 +1798,11 @@ class OutputPeekTree extends Disposable {
17981798
this._register(this.tree.onContextMenu(e => this.onContextMenu(e)));
17991799

18001800
this.tree.setChildren(null, getRootChildren());
1801+
for (const result of results.results) {
1802+
if (!result.completedAt && result instanceof LiveTestResult) {
1803+
attachToResults(result);
1804+
}
1805+
}
18011806
}
18021807

18031808
public layout(height: number, width: number) {
@@ -1880,8 +1885,6 @@ class TestRunElementRenderer implements ICompressibleTreeRenderer<ITreeElement,
18801885

18811886
/** @inheritdoc */
18821887
public renderElement(element: ITreeNode<ITreeElement, FuzzyScore>, _index: number, templateData: TemplateData): void {
1883-
templateData.elementDisposable.clear();
1884-
templateData.elementDisposable.add(element.element.onDidChange(() => this.doRender(element.element, templateData)));
18851888
this.doRender(element.element, templateData);
18861889
}
18871890

@@ -1890,7 +1893,15 @@ class TestRunElementRenderer implements ICompressibleTreeRenderer<ITreeElement,
18901893
templateData.templateDisposable.dispose();
18911894
}
18921895

1896+
/** Called to render a new element */
18931897
private doRender(element: ITreeElement, templateData: TemplateData) {
1898+
templateData.elementDisposable.clear();
1899+
templateData.elementDisposable.add(element.onDidChange(() => this.doRender(element, templateData)));
1900+
this.doRenderInner(element, templateData);
1901+
}
1902+
1903+
/** Called, and may be re-called, to render or re-render an element */
1904+
private doRenderInner(element: ITreeElement, templateData: TemplateData) {
18941905
if (element.labelWithIcons) {
18951906
dom.reset(templateData.label, ...element.labelWithIcons);
18961907
} else if (element.description) {

0 commit comments

Comments
 (0)