GNU bug report logs -
#59633
29.0.50; tree-sitter-bash: Incorrect behaviour of heredocs with expansions
Previous Next
Reported by: miha <at> kamnitnik.top
Date: Sun, 27 Nov 2022 16:32:01 UTC
Severity: normal
Found in version 29.0.50
Done: <miha <at> kamnitnik.top>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Yuan Fu <casouri <at> gmail.com> writes:
> <miha <at> kamnitnik.top> writes:
>
>> Yuan Fu <casouri <at> gmail.com> writes:
>>
>>> What’s the return value of (treesit-node-at (point)) at that point?
>>> Probably the command_substitution node, and since it doesn’t have any
>>> children, treesit-node-first-child-for-pos would return nil.
>>
>> (treesit-node-at (point) 'bash)
>> => #<treesit-node (heredoc_body) in 12-56>
>>
>> I forgot to say that point is before "text2", outside of the
>> command_substitution node.
>>
>>> Yuan
>>
>> tee << EOF
>> text1 $var
>> text2 $(echo cmd)
>> text3
>> $var2
>> EOF
>>
>>
>> Filling a test buffer with these contents and placing point before
>> "text2", we get
>>
>> (treesit-node-at (point) 'bash)
>> => #<treesit-node (heredoc_body) in 12-56>
>>
>> (treesit-node-children (treesit-node-at (point) 'bash))
>> => (#<treesit-node (simple_expansion) in 18-22>
>> #<treesit-node (command_substitution) in 29-40>
>> #<treesit-node (simple_expansion) in 47-52>)
>>
>> This is now expected.
>>
>> (point)
>> => 23
>>
>> (treesit-node-first-child-for-pos (treesit-node-at (point) 'bash) (point))
>> => nil
>>
>> This is not expected. One would expect this to return
>> command_substitution node, since it follows the position 23.
>
> Ah, I (finally) see what you mean. I agree that it should return the
> command_substitution node. It seems that tree-sitter returns nil
> whenever POS is not in a child node. I need to see what’s the problem
> here since treesit-node-first-child-for-pos is just a think wrapper
> around the C counterpart.
Seems to be tree-sitter-bash problem, I submitted an issue at
https://github.com/tree-sitter/tree-sitter-bash/issues/139
Yuan
This bug report was last modified 2 years and 242 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.