Skip to content

fix: Exclude Trailing \r from Comment Nodes on CRLF-Formatted Files #184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

felix-andreas
Copy link

Currently, when parsing files with CRLF (\r\n) line endings, comment nodes incorrectly include the trailing \r character.

This PR updates the grammar to exclude \r from the comment node content, aligning the behavior with other grammars such as tree-sitter-javascript.

Example Input

# comment

Output of tree-sitter parse

Before this PR

(program [0, 0] - [1, 0]
  (comment [0, 0] - [0, 10]))

Using this PR

(program [0, 0] - [1, 0]
  (comment [0, 0] - [0, 9]))

  • Also fixes formatting of grammar.js in line 74 and 208/209.

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