From b7bf5fec538e2c8e41cc2181d2300c09a868328a Mon Sep 17 00:00:00 2001 From: snutij Date: Thu, 4 Jan 2024 16:13:37 +0100 Subject: [PATCH] assign testItem from children only if matching child --- src/testController.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/testController.ts b/src/testController.ts index 400b9b81..d56fc497 100644 --- a/src/testController.ts +++ b/src/testController.ts @@ -400,15 +400,20 @@ export class TestController { testItems.forEach((test) => { if (testItem) return; - if (test.children.size > 0) { - testItem = this.findTestByActiveLine(editor, test.children); - } else if ( + if ( test.uri?.toString() === editor.document.uri.toString() && test.range?.start.line! <= line && test.range?.end.line! >= line ) { testItem = test; } + + if (test.children.size > 0) { + const childInRange = this.findTestByActiveLine(editor, test.children); + if (childInRange) { + testItem = childInRange; + } + } }); return testItem;