elisp-tree-sitter icon indicating copy to clipboard operation
elisp-tree-sitter copied to clipboard

Zero-length node ranges cannot be found with tsc-get-descendant-for-position-range

Open mickeynp opened this issue 3 years ago • 1 comments

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?

mickeynp avatar Mar 08 '21 21:03 mickeynp

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.

ubolonton avatar Mar 10 '21 13:03 ubolonton