From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.bugs Subject: bug#59633: 29.0.50; tree-sitter-bash: Incorrect behaviour of heredocs with expansions Date: Fri, 2 Dec 2022 16:50:20 -0800 Message-ID: <6767DDE2-911D-487F-A4B6-13DE8A0D0915@gmail.com> References: <871qpocq7s.fsf@miha-pc> <90FF5B60-A9AB-4101-9FE3-8FCAD8B9DCE8@gmail.com> <87o7slbwls.fsf@miha-pc> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10902"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 59633@debbugs.gnu.org To: miha@kamnitnik.top Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 03 01:51:08 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 1p1GkG-0002eY-CC for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 03 Dec 2022 01:51:08 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p1GkC-000226-U8; Fri, 02 Dec 2022 19:51:04 -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 1p1GkA-00020l-IG for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 19:51:02 -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 1p1GkA-0002WW-7V for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 19:51:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p1GkA-0005pD-3F for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 19:51:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 03 Dec 2022 00:51: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.167002863122384 (code B ref 59633); Sat, 03 Dec 2022 00:51:02 +0000 Original-Received: (at 59633) by debbugs.gnu.org; 3 Dec 2022 00:50:31 +0000 Original-Received: from localhost ([127.0.0.1]:49840 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1Gjf-0005oy-2q for submit@debbugs.gnu.org; Fri, 02 Dec 2022 19:50:31 -0500 Original-Received: from mail-pj1-f50.google.com ([209.85.216.50]:39545) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1Gjd-0005oq-7R for 59633@debbugs.gnu.org; Fri, 02 Dec 2022 19:50:30 -0500 Original-Received: by mail-pj1-f50.google.com with SMTP id e7-20020a17090a77c700b00216928a3917so9793646pjs.4 for <59633@debbugs.gnu.org>; Fri, 02 Dec 2022 16:50:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=bNPR26nsxcsTl9oYYl3QtMp9f/X7174b5Cip8oMYAiw=; b=HM3d4EsKe3M2woV1WdvlDta95TBDBrs8fAt4g3xS+6pA7IocMWy17cDkaXZyjJ25oU ODxDP0idImJX3cSNEvhJgudzrXJmaX4ZtIKP6IoxW330hBQFmln0X5y0vZc1M+8J1qpN T5IAtEyl5+Ne0a5tZeaCZrid/Lqe6uaqt6kDrUq6msTpwB4WaFiLpCqbb1R2IR0SqlpQ wKZhHdADxdtxRHb6qoE6ptOQMxS3i1rvaZcnXJZ1NUezRwv8Hbhxj3LtM7U9UzSXct1U JK568jzLkdYkXXbZl6T+wtEkYbi6xu4KNl6AStDSiIHfPhB5MSWQdHwhlrVqorguvPOT yR+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bNPR26nsxcsTl9oYYl3QtMp9f/X7174b5Cip8oMYAiw=; b=dTSmES/nWx7F42Xbz2ZL1tizzCI0vvP3xoXB0Le+zXcwiW5sQ8oHqEGPfBolwCPcu9 9DIbx7lHlJKLp2LYoaHle/kn4lHLrTebWpNq13qUBCPJe8JD/IKUXxcxWxHsJ1jCeuib dDiA7V8f+qnKQ1UoxU3eqOvZDsiZnQ7dh5NrEQoxiLu3IXsnVKb+uuQfe7lALMAyKTLu 8oF+xRKdiPjB8aPe95DoD/5qSpQCzv/TbZlgnwj/zG+DClYzm5uLbnXPhX0vGgILvF0p lePvy/BBdaR7xkQMc2+rPY+kllfdMWuQzEjVE/EwzyxtvLalyoRJGcg3uNvkm4578t0J UrUg== X-Gm-Message-State: ANoB5pnpUPFzOt41RmIID8pn01x84089WSsiACPjiAlkr14hvDmr33Nh ORyC+W9KVKcGEQb0gI8Sxfg= X-Google-Smtp-Source: AA0mqf5gtPlzZeAq2RuTZJwHQrXkPwxFtd0rW+kqHVfBer8EhBwJiBI/1Jw12H064cV28HX7h85dHQ== X-Received: by 2002:a17:90a:460f:b0:218:c47f:ed9a with SMTP id w15-20020a17090a460f00b00218c47fed9amr58700014pjg.19.1670028622403; Fri, 02 Dec 2022 16:50:22 -0800 (PST) Original-Received: from smtpclient.apple (108-241-83-33.lightspeed.irvnca.sbcglobal.net. [108.241.83.33]) by smtp.gmail.com with ESMTPSA id p3-20020a170902e74300b00189988a1a9esm6167976plf.135.2022.12.02.16.50.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Dec 2022 16:50:22 -0800 (PST) In-Reply-To: <87o7slbwls.fsf@miha-pc> X-Mailer: Apple Mail (2.3696.120.41.1.1) 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:249797 Archived-At: > On Dec 2, 2022, at 8:26 AM, miha@kamnitnik.top wrote: >=20 > Yuan Fu writes: >=20 >> miha@kamnitnik.top writes: >>=20 >>> 1. Visit empty buffer test in fundamental mode (C-x b test RET) >>> 2. Insert >>>=20 >>> tee << EOF >>> text1 $var >>> text2 $(echo cmd) >>> text3 >>> $var2 >>> EOF >>>=20 >>> 3. Put point before "text2" >>> 4. M-x load-library RET treesit RET >>> 5. M-: (treesit-node-children (treesit-node-at (point) 'bash)) >>>=20 >>> =3D> (# >>> #) >>>=20 >>> Note that this list is incorrect, "$var2" at the end of heredoc is >>> missing. >>>=20 >>> 6. M-: (treesit-node-first-child-for-pos (treesit-node-at (point) = 'bash) (point)) >>>=20 >>> =3D> nil >>>=20 >>> Expected return value here is # >>>=20 >>> 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. >>>=20 >>> tree-sitter-bash version: 0.19.0.r19.g77cf8a7-1 >>> tree-sitter version: 0.20.7-1 >>>=20 >>> Thanks and best regards. >>=20 >> Thanks. This is the tree produced by tree-sitter, does it match your >> expectation? >>=20 >> (heredoc_body >> (simple_expansion $ (variable_name)) >> (command_substitution $( >> (command >> name: (command_name (word)) >> argument: (word)) >> )) >> (simple_expansion $ (variable_name))) >>=20 >> treesit-node-at gives you the _smallest_ node at point, maybe = that=E2=80=99s why >> you didn=E2=80=99t see expected behavior? >>=20 >> Yuan >=20 > The latest commit to tree-sitter-bash is >=20 > commit 4488aa41406547e478636a4fcfd24f5bbc3f2f74 > Author: Jo=C3=A3o P. L. Carvalho > Date: Sun Nov 27 20:39:41 2022 -0700 >=20 > Fix scanning of heredoc_body to allow empty bodies (#137). >=20 > Seems like it has fixed the problem described in the 5. step and the > tree produced by tree-sitter is now expected. >=20 > The problem in the 6. step is still present though. With point in = front > of command_substitution, on would expect >=20 > (treesit-node-first-child-for-pos (treesit-node-at (point) 'bash) = (point)) >=20 > to return the command_substitution node instead of returning nil. What=E2=80=99s the return value of (treesit-node-at (point)) at that = point? Probably the command_substitution node, and since it doesn=E2=80=99= t have any children, treesit-node-first-child-for-pos would return nil. Yuan=