Skip to content

Commit 53eccae

Browse files
committed
Fix GUI performance issue when saving edited test files and updating the Test Explorer pane and editor test markers
1 parent 0fbd4f4 commit 53eccae

2 files changed

Lines changed: 32 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Display per entity and per predicate coverage data in the Test Explorer coverage sub-view (requires Logtalk 3.98.0 or later)
66
* Refactor the use of snippets data by both completion and hover services
77
* Workaround a bug where test results are wrongly routed to the linter possibly due to a race condition when cleaning up the scratch messages file
8+
* Fix GUI performance issue when saving edited test files and updating the Test Explorer pane and editor test markers
89

910
## [0.86.1]
1011

src/features/testsExplorer.ts

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,12 +2107,14 @@ export class LogtalkTestsExplorerProvider implements Disposable {
21072107
});
21082108
});
21092109

2110-
// Mark individual tests as needing re-run (shows enqueued icon)
2111-
// Use individual test runs to avoid resetting the counter for other files
2112-
for (const testItem of individualTestItems) {
2113-
this.markTestAsNeedsRerun(testItem);
2110+
if (individualTestItems.length === 0) {
2111+
return;
21142112
}
21152113

2114+
// Mark all tests as needing re-run in a single batched test run
2115+
// This is much more efficient than creating individual test runs for each test
2116+
this.markTestsAsNeedsRerunBatched(individualTestItems);
2117+
21162118
this.logger.debug(`Marked ${individualTestItems.length} test(s) as needing re-run for file: ${fileUri.fsPath}`);
21172119
}
21182120

@@ -2256,7 +2258,32 @@ export class LogtalkTestsExplorerProvider implements Disposable {
22562258
testRun.end();
22572259
}
22582260

2261+
/**
2262+
* Mark multiple tests as needing to be re-run using a single batched test run.
2263+
* This is much more efficient than creating individual test runs for each test,
2264+
* especially when invalidating test results for files with many tests.
2265+
* @param testItems - Array of test items to mark as needing re-run
2266+
*/
2267+
private markTestsAsNeedsRerunBatched(testItems: TestItem[]): void {
2268+
if (testItems.length === 0) {
2269+
return;
2270+
}
22592271

2272+
// Create a single test run for all items - this triggers only one UI update cycle
2273+
const testRun = this.controller.createTestRun(
2274+
new TestRunRequest(testItems),
2275+
'Tests modified - need re-run',
2276+
false
2277+
);
2278+
2279+
// Enqueue all test items in the same test run
2280+
for (const testItem of testItems) {
2281+
testRun.enqueued(testItem);
2282+
}
2283+
2284+
// End the test run once after all items are enqueued
2285+
testRun.end();
2286+
}
22602287

22612288
/**
22622289
* Check if a test has a condition option that prevents skipping.

0 commit comments

Comments
 (0)