Current behavior
Case 1
Given a file with these contents (cursor marked with |:
This is parsed as:
(source_file ; [0, 0] - [1, 0]
(text) ; [0, 0] - [0, 4]
(emph ; [0, 5] - [0, 11]
"_" ; [0, 5] - [0, 6]
(text) ; [0, 6] - [0, 10]
"_")) ; [0, 10] - [0, 11]
The current node here is marked as the first anonymous _. This behavior is identical for other node types - $$, <>, **, etc.
Case 2
If the file only contains some node:
This is parsed as:
(source_file ; [0, 0] - [1, 0]
(code ; [0, 0] - [0, 3]
"#" ; [0, 0] - [0, 1]
(block ; [0, 1] - [0, 3]
"{" ; [0, 1] - [0, 2]
"}") ; [0, 2] - [0, 3]
"end")) ; [0, 3] - [0, 3]
The current node here is actually source_file - before code and the anonymous #.
Expected behavior
I hit this because I was writing some query logic, and expected that if my cursor was before a delimiter starting a node, it wouldn't count as being within that node. For this reason, I think the logic should be adapted to consistently match case two. However, I can work around this if need be, so I'd be happy with any form of consistency.
Current behavior
Case 1
Given a file with these contents (cursor marked with
|:This is parsed as:
The current node here is marked as the first anonymous
_. This behavior is identical for other node types -$$,<>,**, etc.Case 2
If the file only contains some node:
This is parsed as:
The current node here is actually
source_file- beforecodeand the anonymous#.Expected behavior
I hit this because I was writing some query logic, and expected that if my cursor was before a delimiter starting a node, it wouldn't count as being within that node. For this reason, I think the logic should be adapted to consistently match case two. However, I can work around this if need be, so I'd be happy with any form of consistency.