unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Yuan Fu <casouri@gmail.com>
To: miha@kamnitnik.top
Cc: 59633@debbugs.gnu.org
Subject: bug#59633: 29.0.50; tree-sitter-bash: Incorrect behaviour of  heredocs with expansions
Date: Tue, 13 Dec 2022 20:01:31 -0800	[thread overview]
Message-ID: <91CDE39D-4598-480D-B84B-5E3E152B15BC@gmail.com> (raw)
In-Reply-To: <871qpocq7s.fsf@miha-pc>


Yuan Fu <casouri@gmail.com> writes:

> <miha@kamnitnik.top> writes:
>
>> Yuan Fu <casouri@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





  parent reply	other threads:[~2022-12-14  4:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-27 16:33 bug#59633: 29.0.50; tree-sitter-bash: Incorrect behaviour of heredocs with expansions miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-02  5:25 ` Yuan Fu
2022-12-02 16:26   ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-03  0:50     ` Yuan Fu
2022-12-03  7:25       ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-09 22:10 ` Yuan Fu
2022-12-14  4:01 ` Yuan Fu [this message]
2022-12-14 15:07   ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=91CDE39D-4598-480D-B84B-5E3E152B15BC@gmail.com \
    --to=casouri@gmail.com \
    --cc=59633@debbugs.gnu.org \
    --cc=miha@kamnitnik.top \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).