all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: miha--- via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Yuan Fu <casouri@gmail.com>
Cc: 59633@debbugs.gnu.org
Subject: bug#59633: 29.0.50; tree-sitter-bash: Incorrect behaviour of heredocs with expansions
Date: Fri, 02 Dec 2022 17:26:23 +0100	[thread overview]
Message-ID: <87o7slbwls.fsf@miha-pc> (raw)
In-Reply-To: <90FF5B60-A9AB-4101-9FE3-8FCAD8B9DCE8@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2124 bytes --]

Yuan Fu <casouri@gmail.com> writes:

> miha@kamnitnik.top writes:
>
>> 1. Visit empty buffer test in fundamental mode (C-x b test RET)
>> 2. Insert
>>
>> tee << EOF
>> text1 $var
>> text2 $(echo cmd)
>> text3
>> $var2
>> EOF
>>
>> 3. Put point before "text2"
>> 4. M-x load-library RET treesit RET
>> 5. M-: (treesit-node-children (treesit-node-at (point) 'bash))
>>
>>     => (#<treesit-node (simple_expansion) in 18-22>
>>         #<treesit-node (command_substitution) in 29-40>)
>>
>>    Note that this list is incorrect, "$var2" at the end of heredoc is
>>    missing.
>>
>> 6. M-: (treesit-node-first-child-for-pos (treesit-node-at (point) 'bash) (point))
>>
>>    => nil
>>
>>    Expected return value here is #<treesit-node (command_substitution) in 29-40>
>>
>> I'm not sure if this bug is on Emacs, tree-sitter-bash or even
>> tree-sitter itself and I don't know how to check.
>>
>> tree-sitter-bash version: 0.19.0.r19.g77cf8a7-1
>> tree-sitter version: 0.20.7-1
>>
>> Thanks and best regards.
>
> Thanks. This is the tree produced by tree-sitter, does it match your
> expectation?
>
> (heredoc_body
> (simple_expansion $ (variable_name))
> (command_substitution $(
>   (command
>    name: (command_name (word))
>    argument: (word))
>   ))
> (simple_expansion $ (variable_name)))
>
> treesit-node-at gives you the _smallest_ node at point, maybe that’s why
> you didn’t see expected behavior?
>
> Yuan

The latest commit to tree-sitter-bash is

commit 4488aa41406547e478636a4fcfd24f5bbc3f2f74
Author: João P. L. Carvalho <jaopaulolc@gmail.com>
Date:   Sun Nov 27 20:39:41 2022 -0700

    Fix scanning of heredoc_body to allow empty bodies (#137).

Seems like it has fixed the problem described in the 5. step and the
tree produced by tree-sitter is now expected.

The problem in the 6. step is still present though. With point in front
of command_substitution, on would expect

    (treesit-node-first-child-for-pos (treesit-node-at (point) 'bash) (point))

to return the command_substitution node instead of returning nil.

Thanks.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]

  reply	other threads:[~2022-12-02 16:26 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 [this message]
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
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

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

  git send-email \
    --in-reply-to=87o7slbwls.fsf@miha-pc \
    --to=bug-gnu-emacs@gnu.org \
    --cc=59633@debbugs.gnu.org \
    --cc=casouri@gmail.com \
    --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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.