tree-sitter / tree-sitter-ruby

Ruby grammar for tree-sitter
MIT License
182 stars 58 forks source link

Incomplete method definition parses as if it ends on the first line #234

Open dgutov opened 1 year ago

dgutov commented 1 year ago

The file contents like:

def foo
|

(| denotes the cursor)

parse without error to structure

(program
 (method def body: (identifier) end))

which on its own is a bit surprising (a virtual "end"?), but the really unfortunate part is that the end of the parsed node is put on the first line, thus the second line is essentially said to be outside of the method (as any straightforward analyzer of the parse tree would conclude). Which makes things more difficult for indentation code.

Could we position the "virtual end" at the end of the file in this example?