From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#66988: 30.0.50; treesit-forward-sexp not working properly in js-ts-mode and tsx-ts-mode Date: Fri, 10 Nov 2023 03:41:00 +0200 Message-ID: <39b0057b-ac0c-8271-0fe2-f4deef7ae8d3@gutov.dev> References: <9cf7d7d0-33a3-4c07-bd66-bc4c59bdfefb@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39937"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 To: =?UTF-8?Q?Lo=C3=AFc_?= =?UTF-8?Q?Lema=C3=AEtre?= , 66988@debbugs.gnu.org, Yuan Fu , Theodor Thornhill Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Nov 10 02:41:54 2023 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 1r1GWu-000A9k-CE for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 10 Nov 2023 02:41:53 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r1GWT-00088W-TA; Thu, 09 Nov 2023 20:41:25 -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 1r1GWQ-000834-VE for bug-gnu-emacs@gnu.org; Thu, 09 Nov 2023 20:41:22 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r1GWQ-0000A9-M9 for bug-gnu-emacs@gnu.org; Thu, 09 Nov 2023 20:41:22 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r1GX3-0004YM-TX for bug-gnu-emacs@gnu.org; Thu, 09 Nov 2023 20:42:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 10 Nov 2023 01:42:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66988 X-GNU-PR-Package: emacs Original-Received: via spool by 66988-submit@debbugs.gnu.org id=B66988.169958051517477 (code B ref 66988); Fri, 10 Nov 2023 01:42:01 +0000 Original-Received: (at 66988) by debbugs.gnu.org; 10 Nov 2023 01:41:55 +0000 Original-Received: from localhost ([127.0.0.1]:49217 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r1GWx-0004Xp-11 for submit@debbugs.gnu.org; Thu, 09 Nov 2023 20:41:55 -0500 Original-Received: from out3-smtp.messagingengine.com ([66.111.4.27]:34241) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r1GWr-0004XV-BK for 66988@debbugs.gnu.org; Thu, 09 Nov 2023 20:41:53 -0500 Original-Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailout.nyi.internal (Postfix) with ESMTP id D66D15C0244; Thu, 9 Nov 2023 20:41:03 -0500 (EST) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Thu, 09 Nov 2023 20:41:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1699580463; x=1699666863; bh=RrBoWK16pYN2MuL3rR9wP1NmjY+I2OeZw2L UiDK0zLU=; b=JP7h7NEDuxD/2PfHb0b8JDgQP58j+IBCHq7Ep+OfBknIWjfZ+D8 6leuLDk/tq62TYhOjepegm4g5EjYu4qev9vdF2iSR29edaS047TZVuHLgdgm4OUd qyXimyQBTaJGhjesiDSqosjCWrYjPGQnzO6lAQUEP7M0uuuuE5oZt5B0u3N41dTA mIMbTLukgEVBYwuJ7ZV2Ln0OQosh+gX1xmc2AZ60Y0Olx1h83ny2TUAoTl925Pgn DH7kRpNudCqMQPCDRf5lI4j/wq9hs2Jgo+bWamBhNUqn1ljVdfklQ0vQTmznYAxy WL4AXpiZivHnBT1PbETIbXT2U6cEiO6vFyw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1699580463; x= 1699666863; bh=RrBoWK16pYN2MuL3rR9wP1NmjY+I2OeZw2LUiDK0zLU=; b=I 5qsYKWAy185HTLhAn7XZm/pIN0TVJyLvL2pPGFclSCwPeCHDqMkefi/lopxtnJji njuxNOdAiItDTsmvEA5q3wqRS7bC6cPgNFscTvpgccL+ubE9Wy4Pq6fZ5Rj8/GnX 2KxQSJStiKQJCSZ1fq+IljGjQrD48+Eio2VFV7ig5juJkm0mevoYR2HJvZwVw4jM jLEMaHddDKH7fRhSZB75+k7I/m6u3NQCyi7bt7Isu7BR1JlnON3t5q2AWtCjyqFW c+BvjlO20+4oS2BqYkjcBAaL0nVgCXzDI2KG6b6CbvgDWYi2xHf48sZyS3xy6L3F MejKg8FGucUBcGiLxU9Ug== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedruddvvddgfeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvfhfhjggtgfesthekredttdefjeenucfhrhhomhepffhmihht rhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrdguvghvqeenucggtffrrghtth gvrhhnpeefjeekvedvfeelfedufeevgeetvdevkeelvddtueetteefudefgfduieekffei leenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegumh hithhrhiesghhuthhovhdruggvvh X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 9 Nov 2023 20:41:02 -0500 (EST) Content-Language: en-US In-Reply-To: <9cf7d7d0-33a3-4c07-bd66-bc4c59bdfefb@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:274078 Archived-At: Hi! On 07/11/2023 16:56, Loïc Lemaître wrote: > Hi Emacs team, > > Here the steps to demonstrate the bug : > > 1. Compile Emacs from master branch with tree-sitter support > 2. Install javascript and tsx languages > 3. Run Emacs > 4. Create a new buffer > 5. Turn major mode to either js-ts-mode or tsx-ts-mode > 6. Past the following content into the buffer: > ( >  
>  
> ); > 7. Place point before opening parenthese > 8. M-x forward-sexp (which will call treesit-forward-sexp) > > => New position is right after the semi-colon instead of being before > the semi-colon. > > Note that the bug disappear if the buffer content is changed for : > const component = ( >  
>  
> ); > > But previous content, while not being very usefull, is valid JSX, as far > as I know. > I use this syntax for unit test purpose, since it is very short. Thanks for the report. The patch below should fix it. Yuan, what do you think? A similar change (bos and eos anchors) might be useful for other things and other modes. Alternatively, treesit-thing-settings could be interpreted to imply full matches, then the code using it should not only match against the regexps but also check that the entire string (type name) is matched. Also Cc'ing Theodor. diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 5a669fdbd42..d81fa9ed322 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3843,6 +3843,7 @@ js--treesit-sexp-nodes "undefined" "arguments" "pair" + "parenthesized_expression" "jsx") "Nodes that designate sexps in JavaScript. See `treesit-thing-settings' for more information.") @@ -3886,7 +3887,7 @@ js-ts-mode (setq-local treesit-thing-settings `((javascript - (sexp ,(regexp-opt js--treesit-sexp-nodes)) + (sexp ,(format "\\`%s\\'" (regexp-opt js--treesit-sexp-nodes))) (sentence ,(regexp-opt js--treesit-sentence-nodes)) (text ,(regexp-opt '("comment" "template_string"))))))