@@ -348,12 +348,36 @@ export class TestControllerManager {
348
348
let tests = robotItem?.children;
349
349
350
350
if (robotItem?.type === "suite" && item.uri !== undefined) {
351
+ if (robotItem.children === undefined) robotItem.children = [];
352
+
351
353
const openDoc = vscode.workspace.textDocuments.find((d) => d.uri.toString() === item.uri?.toString());
352
354
353
355
if (openDoc !== undefined) {
354
356
tests = await this.languageClientsManager.getTestsFromDocument(openDoc, robotItem.longname, token);
357
+
358
+ if (tests !== undefined) {
359
+ for (const test of tests) {
360
+ const index = robotItem.children.findIndex((v) => v.id === test.id);
361
+ if (index >= 0 && robotItem.children) {
362
+ robotItem.children[index] = test;
363
+ } else {
364
+ robotItem.children.push(test);
365
+ }
366
+ }
367
+
368
+ const removed = robotItem.children.filter((v) => tests?.find((w) => w.id === v.id) === undefined);
369
+
370
+ robotItem.children = robotItem.children.filter((v) => removed.find((w) => w.id == v.id) === undefined);
371
+ } else {
372
+ robotItem.children = [];
373
+ }
374
+
375
+ robotItem.children = robotItem.children.sort(
376
+ (a, b) => (a.range?.start.line || -1) - (b.range?.start.line || -1)
377
+ );
355
378
}
356
379
}
380
+
357
381
if (token?.isCancellationRequested) return;
358
382
359
383
if (robotItem) {
@@ -372,7 +396,7 @@ export class TestControllerManager {
372
396
}
373
397
374
398
// TODO: we need a sleep after deletion here, it seem's there is a bug in vscode
375
- if (this.removeNotAddedTestItems(item, addedIds)) await sleep(500 );
399
+ if (this.removeNotAddedTestItems(item, addedIds)) await sleep(5 );
376
400
}
377
401
} finally {
378
402
item.busy = false;
@@ -408,7 +432,7 @@ export class TestControllerManager {
408
432
}
409
433
410
434
// TODO: we need a sleep after deletion here, it seem's there is a bug in vscode
411
- if (this.removeNotAddedTestItems(undefined, addedIds)) await sleep(500 );
435
+ if (this.removeNotAddedTestItems(undefined, addedIds)) await sleep(5 );
412
436
}
413
437
}
414
438
@@ -498,7 +522,7 @@ export class TestControllerManager {
498
522
this.removeWorkspaceFolderItems(w);
499
523
}
500
524
}
501
- await sleep(500 );
525
+ await sleep(5 );
502
526
await this.refresh();
503
527
});
504
528
}
0 commit comments