elisp-tree-sitter
elisp-tree-sitter copied to clipboard
Zero-length node ranges cannot be found with tsc-get-descendant-for-position-range
First of all, great package!
Consider the following Python example:
if True:
And the following tree:
module (1 . 9)
if_statement (1 . 9)
true (4 . 8)
block (9 . 9)
Putting point at the end of the line of code and calling either (tsc-node-byte-range (tree-sitter-node-at-point))
or (tsc-node-byte-range (tsc-get-descendant-for-position-range (tsc-root-node tree-sitter-tree) (point) (point)))
yields (1 . 9)
or the module block range and not (9 . 9)
as expected.
Is this a bug or a quirk in tree-sitter?
IIRC, tree-sitter
disallows zero-length rules, and has a generation-time check for this. This looks like a bug in either the (CLI) generator, or in tree-sitter-python
.