fix: range end line was still 1-based causing it to bleed into the next line#757
fix: range end line was still 1-based causing it to bleed into the next line#757SivanRP wants to merge 1 commit intomicrosoft:mainfrom
Conversation
…xt line Fixes #38911 I was looking into why Test Explorer arrows were misaligned and traced it back to this - Playwright counts lines starting at 1, but VS Code's Range API uses 0-based line numbers. The start line was already being converted with `line - 1`, but the end line was still using the raw value, so every TestItem range stretched one line further than the actual test() call. The fix is to use the same converted value for both start and end. I also removed the else-if branch below it since it could never actually run. Added tests/location.spec.ts to catch this if it comes up again.
|
@SivanRP please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
Skn0tt
left a comment
There was a problem hiding this comment.
Good job spotting the dead code! I wonder how that came to be.
My understanding is that VS Code places the green test triangle at the beginning of the test item range, so fixing the end location shouldn't impact anything.
Can you reproduce the bug from the issue, where the green triangles are misaligned? In my testing, everything looks good.
Fixes #38911
What was wrong
I was digging into why Test Explorer arrows were showing up on the wrong lines and found it in
_syncSuiteinsidesrc/testTree.ts. Playwright gives us line numbers starting at 1, but VS Code'sRangeAPI uses 0-based line numbers (line 0 = first line of the file).The start line was already being converted correctly with
line - 1, but the end line was still using the raw value from Playwright. So everyTestItemrange was stretching one line further than the actualtest()call.What I changed
src/testTree.ts— compute a singlezeroBasedvalue and use it for both start and end of theRange:I also removed the
else ifbranch below it — it could never actually execute because the conditions were mutually exclusive.tests/location.spec.ts— added a regression test that checksrange.start.line === range.end.line(which would have failed on the old code) and verifies the start line is the correct 0-based value.