Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

Fix Run Current Test In Terminal for class line #961

Merged
merged 1 commit into from
Jan 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/testController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't this be an else if? Am I misunderstanding the conditional on line 403?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is not possible, for example:

class Foo 
 
  def test_one # cursor here
    assert(true)
  end

end

The first condition will match (parent test range match the cursor) but you want to override the testItem value with child. Is it clearer?

const childInRange = this.findTestByActiveLine(editor, test.children);
if (childInRange) {
testItem = childInRange;
}
}
});

return testItem;
Expand Down