You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have read all the tree-sitter docs if it relates to using the parser
I have searched the existing issues of tree-sitter-python
Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)
tree-sitter 0.22.3
Describe the bug
Using old_tree.changed_ranges(new_tree) Python parser does not detect removal or insertion of node escape_sequence when switching between plain string and r-prefixed-string.
Toggling of prefix r for the string results in a change of node string_start, but while string_content, parent of escape_sequence, has no changes in content, its structure changes when escape_sequence is detected/ignored.
Note that it seems that the equivalent changes to f-prefixed-string are detected as expected.
P.S. Sorry for example written in Python, but I don't know C/CLI scripts to reproduce the bug. Toggle commented/uncommented strings to switch between r-string and f-string.
Steps To Reproduce/Bad Parse Tree
Create text file with a string containing escape sequence: "for whom the \x07 {'tolls'}".
Parse it to get tree A: (module (expression_statement (string (string_start) (string_content (escape_sequence)) (string_end)))).
Edit string by adding prefix r: r"for whom the \x07 {'tolls'}".
Parse it to get tree B: (module (expression_statement (string (string_start) (string_content) (string_end)))).
Call A.changed_ranges(B), and receive this output: [<Range ... start_byte=0, end_byte=1>].
Edit string by removing prefix r: "for whom the \x07 {'tolls'}".
Parse it to get tree C: (module (expression_statement (string (string_start) (string_content (escape_sequence)) (string_end)))).
Call B.changed_ranges(C), and receive this output: [].
Expected Behavior/Parse Tree
A.changed_ranges(B) should have resulted in this output: [<Range ... start_byte=0, end_byte=1>, <Range ... start_byte=15, end_byte=19>]. B.changed_ranges(C) should have resulted in this output (indexes are approximate and should have spanned same range as escape sequence): [<Range ... start_byte=14, end_byte=18>].
Did you check existing issues?
Tree-Sitter CLI Version, if relevant (output of
tree-sitter --version
)tree-sitter 0.22.3
Describe the bug
Using
old_tree.changed_ranges(new_tree)
Python parser does not detect removal or insertion of nodeescape_sequence
when switching between plain string and r-prefixed-string.Toggling of prefix
r
for the string results in a change of nodestring_start
, but whilestring_content
, parent ofescape_sequence
, has no changes in content, its structure changes whenescape_sequence
is detected/ignored.Note that it seems that the equivalent changes to f-prefixed-string are detected as expected.
P.S. Sorry for example written in Python, but I don't know C/CLI scripts to reproduce the bug. Toggle commented/uncommented strings to switch between r-string and f-string.
Steps To Reproduce/Bad Parse Tree
"for whom the \x07 {'tolls'}"
.A
:(module (expression_statement (string (string_start) (string_content (escape_sequence)) (string_end))))
.r
:r"for whom the \x07 {'tolls'}"
.B
:(module (expression_statement (string (string_start) (string_content) (string_end))))
.A.changed_ranges(B)
, and receive this output:[<Range ... start_byte=0, end_byte=1>]
.r
:"for whom the \x07 {'tolls'}"
.C
:(module (expression_statement (string (string_start) (string_content (escape_sequence)) (string_end))))
.B.changed_ranges(C)
, and receive this output:[]
.Expected Behavior/Parse Tree
A.changed_ranges(B)
should have resulted in this output:[<Range ... start_byte=0, end_byte=1>, <Range ... start_byte=15, end_byte=19>]
.B.changed_ranges(C)
should have resulted in this output (indexes are approximate and should have spanned same range as escape sequence):[<Range ... start_byte=14, end_byte=18>]
.Repro
The text was updated successfully, but these errors were encountered: