Skip to content

fix(highlight): account for multiple rows in highlight testing assertions#4333

Merged
WillLillis merged 2 commits intotree-sitter:masterfrom
WillLillis:highlight_test
Apr 6, 2025
Merged

fix(highlight): account for multiple rows in highlight testing assertions#4333
WillLillis merged 2 commits intotree-sitter:masterfrom
WillLillis:highlight_test

Conversation

@WillLillis
Copy link
Member

This highlight test case is currently broken:

echo
"\ lorem ipsum
" <- @comment

I believe the issue is that the line_continuation_comment node starts at position [0,4], rather than [1,0]. This starting position causes this if block to incorrectly enter. Even though the highlight's column is past the position's end column, the highlight starts a row earlier. The fix is to just make sure the highlight's row is considered in addition to the column.

Bonus commit: Noticed this while debugging this issue. When zero test cases are parsed, "NaN%" is displayed for the success percentage and "0 bytes/ms" is shown for the parse rate. When no (measured) parsing took place, we don't have a valid success or parse rates to display. N/A seems more correct in this case.

cc @clason

@clason clason added the ci:backport release-0.25 Backport label label Apr 6, 2025
@WillLillis
Copy link
Member Author

WillLillis commented Apr 6, 2025

The tree-sitter-lua test case you mentioned passes with these changes as well. I'm not sure if it should be though.

Edit It definitely seems to be similar-ish to the tree-sitter-vim issue. The escape_sequence node's starting range extends to both of the string literal's lines.

@clason
Copy link
Contributor

clason commented Apr 6, 2025

Yeah, that seems like a different error (that it passes)? (Possibly the arrow tests are more broadly bugged.)

@clason
Copy link
Contributor

clason commented Apr 6, 2025

Ah, no, I see now why the test should pass -- it's explicitly testing that the node extends across lines. (Bit of a weird test, tho.)

So these changes are good!

@WillLillis WillLillis merged commit 0f94916 into tree-sitter:master Apr 6, 2025
19 checks passed
@WillLillis WillLillis deleted the highlight_test branch April 6, 2025 13:45
@tree-sitter-ci-bot
Copy link

Successfully created backport PR for release-0.25:

@tree-sitter-ci-bot
Copy link

Successfully created backport PR for release-0.25:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test regression with arrows

2 participants