From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: miha--- via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#59633: 29.0.50; tree-sitter-bash: Incorrect behaviour of heredocs with expansions Date: Fri, 02 Dec 2022 17:26:23 +0100 Message-ID: <87o7slbwls.fsf@miha-pc> References: <871qpocq7s.fsf@miha-pc> <90FF5B60-A9AB-4101-9FE3-8FCAD8B9DCE8@gmail.com> Reply-To: Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12978"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 59633@debbugs.gnu.org To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Dec 02 17:25:24 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p18qp-00035z-Gb for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 02 Dec 2022 17:25:24 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p18qX-0001jU-KJ; Fri, 02 Dec 2022 11:25:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p18qV-0001jI-Jb for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 11:25:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p18qV-0002RQ-AB for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 11:25:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p18qU-00077w-V4 for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 11:25:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 02 Dec 2022 16:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59633 X-GNU-PR-Package: emacs Original-Received: via spool by 59633-submit@debbugs.gnu.org id=B59633.166999830227391 (code B ref 59633); Fri, 02 Dec 2022 16:25:02 +0000 Original-Received: (at 59633) by debbugs.gnu.org; 2 Dec 2022 16:25:02 +0000 Original-Received: from localhost ([127.0.0.1]:47583 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p18qT-00077b-Q3 for submit@debbugs.gnu.org; Fri, 02 Dec 2022 11:25:02 -0500 Original-Received: from kamnitnik.top ([209.250.245.214]:42516) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p18qQ-00077U-SC for 59633@debbugs.gnu.org; Fri, 02 Dec 2022 11:25:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kamnitnik.top; s=mail; t=1669998294; bh=8vRXZUZxzvfwcYTqXEcPG3S280yyGL+zPEhcUhfcrhw=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=MclphUSr/72+1WMDkbXIAtl8GQwhKqz8SUy3/5siEac6UA/3qCmAMfyLGchXlbtNF O5W3KbED1pjjNFM1Tp92O+r36a+szPEZHpdKHFkMQ0s4Jk4pdAfHRTusHBWSeaN6o4 7ndHVfiHWXK//rut7tbCnJuszGx49ZJa9MvZdDZ8mVQ/ap+fCPPEwSOZf7iQAFwK97 y6dMAJNwk8gwdICt7BGR6gANUJfNRmkT1+pAqGkLsIzziSsjT7GgQYhZhubMUMDUTI 6Ix+HtqoXdVPNlklA3gHilurK1Bc1MhEN5ncS3pdkRFBa5N9RS5Kqy/t0h/sliQLpB DEeAWW7XnECQw== In-Reply-To: <90FF5B60-A9AB-4101-9FE3-8FCAD8B9DCE8@gmail.com> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:249765 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Yuan Fu 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)) >> >> =3D> (# >> #) >> >> 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)) >> >> =3D> nil >> >> Expected return value here is # >> >> 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=E2=80= =99s why > you didn=E2=80=99t see expected behavior? > > Yuan The latest commit to tree-sitter-bash is commit 4488aa41406547e478636a4fcfd24f5bbc3f2f74 Author: Jo=C3=A3o P. L. Carvalho 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) (poin= t)) to return the command_substitution node instead of returning nil. Thanks. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJHBAEBCAAxFiEEmxVnesoT5rQXvVXnswkaGpIVmT8FAmOKJy8THG1paGFAa2Ft bml0bmlrLnRvcAAKCRCzCRoakhWZP4PcD/43OLOVc/tYOFLLZALo5Cu22WPyXS7B btIXBmyZF3RxTfklQRzYujRlwEONxDm3FvuU7sFm9rK56ZB9SQ/gJ4GIr+akCKjC kD7CXnRdc1u9C88sS9bsbq/l/UQ+iJhXakoITH9FRfxe21oVWN9UFbsPxI1KG+sR h92lFYv5G6sZixBlw5PhOMOFVt7q3txmPGO8BUX2cKsRnXIIITb0LzO0PAa+MdjE hOQhp2MDyYLSULT+TsGA6HwbruAuwJ4zvbPxOU/v/B+RXVuRHoRKWyPGBFJWnoxF rOok1nzPCHPvYAAnwNoQmsKLJwXPSXBVVnBxCYngJTU/QoiSuxl0sHxnf558gkcT /6xav3G91D0/N18CEr2BWkbT4P9F60dF2WTQ2mecmCm5efDqy54F1B/+6vAnWI7k emQfoQweQaTt6LPzXzysgRThAbo5/uRSnZtJAOWgqytZCshHPckqvZLPmYetUNN5 Ev3BHpc4TSAr4GCffdbD4+2WdehWH7T4iZASR3e1Ktfh57KV5B0TD/HMivjOmrHz ET+hlHIOf9VotjeGIxFzn4Rx95V+kJgUlG4h/VRkbIxp1ZtlsqWewg2WJa0c+7OE V1XWNV05f3DkoHXkYlbkoHmmPMZuJtGNXlaeS09eGZ5qAApK9i97Id/d9INUA8XF DdfKWLwFy/KCXA== =um/T -----END PGP SIGNATURE----- --=-=-=--