@@ -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