Skip to content

Correctly parse line comments on Windows/CRLF line endings#67

Open
sebastien-marichal wants to merge 1 commit intoaheber:mainfrom
sebastien-marichal:sma/line-comment-crlf
Open

Correctly parse line comments on Windows/CRLF line endings#67
sebastien-marichal wants to merge 1 commit intoaheber:mainfrom
sebastien-marichal:sma/line-comment-crlf

Conversation

@sebastien-marichal
Copy link

@sebastien-marichal sebastien-marichal commented Nov 27, 2025

line_comment was incorrectly including the \r character on file using CRLF (Windows).

This change updates the regex in the line_comment rule to explicitly exclude \r along with \n, changing the match pattern from /[^\n]*/ to /[^\r\n]*/.

I was not able to add a test in corpus. I tried to use the :cst attribute with no avail so I could assert node length.


Given the following file (with CRLF):

// test comment

Here the previous parse value:

0:0  - 1:0    parser_output
0:0  - 0:16     line_comment `// test comment\r`

Now with the fix:

0:0  - 1:0    parser_output
0:0  - 0:15     line_comment `// test comment`

Command used for the output: tree-sitter.exe parse --cst .\test.crlf.cls

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant