Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
include leading whitespace in $.message
see helix-editor/helix#1338 (comment) Leading whitespace is important when injecting diff highlights into messages trailing the scissors. Without this change, some adverserial context lines can end up being mistakenly parsed as non-$.context rules. For example, in the screenshot of the linked issue comment, a context line is being parsed by a tricky link that looks like a malformed $.similarity rule. Because NEWLINE is not a child of $._line but $.source in tree-sitter-git-diff, part of the line is re-parsed into another valid $._line rule, namely $.addition in this case. For an example COMMIT_EDITMSG which has a second diff line 6 characters to the right of the newline, this commit changes the start column of the parsed $.message node to include the whitespace: (source [0, 0] - [7, 0] (subject [0, 0] - [0, 53]) (comment [2, 0] - [4, 38] (scissors [2, 0] - [4, 38])) (message [5, 0] - [5, 36]) - (message [6, 5] - [6, 80])) + (message [6, 0] - [6, 80])) This change probably restricts this grammar to tree-sitter 0.20.1+ because the WHITE_SPACE 'extra' is now used as an extra and within a rule (see tree-sitter/tree-sitter#1444 (comment)) but trailing diffs are not meant to be edited anyways, so it's probably not a big deal.
- Loading branch information
066e395
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> a tricky line