From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Augustin =?UTF-8?Q?Ch=C3=A9neau?= (BTuin) Newsgroups: gmane.emacs.bugs Subject: bug#65470: 29.1.50; js-ts-mode: regex pattern can cause incorrect parenthesis matching Date: Fri, 25 Aug 2023 09:17:07 +0200 Message-ID: <96820db7-cd69-43eb-81d6-3822312cd928@mailo.com> References: <59d884e2-4190-7111-8a37-548eb5a2c732@gutov.dev> <83fs49q8ui.fsf@gnu.org> <87bkew6x4y.fsf@thornhill.no> <3f955b21-1394-a7bd-ed35-064d8731e751@gutov.dev> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------1t7DedAiwq7MVMG8YRUu7fOa" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22913"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird Cc: 65470@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Aug 25 09:18:20 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 1qZR5I-0005jh-06 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 25 Aug 2023 09:18:20 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZR4z-0008Ka-QX; Fri, 25 Aug 2023 03:18:01 -0400 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 1qZR4y-0008K7-1r for bug-gnu-emacs@gnu.org; Fri, 25 Aug 2023 03:18:00 -0400 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 1qZR4x-0002cB-Pt for bug-gnu-emacs@gnu.org; Fri, 25 Aug 2023 03:17:59 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qZR50-0004kV-Gp for bug-gnu-emacs@gnu.org; Fri, 25 Aug 2023 03:18:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Augustin =?UTF-8?Q?Ch=C3=A9neau?= (BTuin) Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 25 Aug 2023 07:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65470 X-GNU-PR-Package: emacs Original-Received: via spool by 65470-submit@debbugs.gnu.org id=B65470.169294784718205 (code B ref 65470); Fri, 25 Aug 2023 07:18:02 +0000 Original-Received: (at 65470) by debbugs.gnu.org; 25 Aug 2023 07:17:27 +0000 Original-Received: from localhost ([127.0.0.1]:39113 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZR4Q-0004jZ-Jx for submit@debbugs.gnu.org; Fri, 25 Aug 2023 03:17:27 -0400 Original-Received: from msg-2.mailo.com ([213.182.54.12]:52580) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZR4N-0004jJ-2P for 65470@debbugs.gnu.org; Fri, 25 Aug 2023 03:17:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1692947828; bh=PqzvIJ4OSzmIlxWZ534rxmeuyTQqkiLhsf9M60KoSu0=; h=X-EA-Auth:Content-Type:Message-ID:Date:MIME-Version:Subject:To: References:From:Cc:In-Reply-To; b=MxzqMffYx9Dhqc70ibVvB+hqLRkK6zZO+1ZnhHwTpquNLX0t4wx52VdTT9DnTnLHZ B5Imt9LDb04YruUMA3mCwWNwEy0i+XcPOGBIo/FW5fdVfXAYS1awDxcgaMx/PGQ4Cq WaE7frcoKAsCEO7iY6cat77ledPBdyhlcvhMhYzA= Original-Received: by b221-4.in.mailobj.net [192.168.90.24] with ESMTP via ip-20.mailobj.net [213.182.54.20] Fri, 25 Aug 2023 09:17:07 +0200 (CEST) X-EA-Auth: CdiMyfAu2d4AGr+SwLKn4rW4+x14Um1LUe6ZuItRWL3tDmVki3zDuTB/eWpHiO7ocBlNKObNKpTDkftOM+l6sXQ9dqEaBIxa Content-Language: fr, en-US In-Reply-To: <3f955b21-1394-a7bd-ed35-064d8731e751@gutov.dev> 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:268403 Archived-At: This is a multi-part message in MIME format. --------------1t7DedAiwq7MVMG8YRUu7fOa Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Le 25/08/2023 à 02:18, Dmitry Gutov a écrit : > On 24/08/2023 22:47, Theodor Thornhill wrote: >> Eli Zaretskii  writes: >> >>>> Date: Wed, 23 Aug 2023 16:23:13 +0300 >>>> From: Dmitry Gutov >>>> >>>> On 23/08/2023 12:05, Augustin Chéneau (BTuin) wrote: >>>>> With the mode js-ts-mode, matching tokens (such as '()', '[]') can be >>>>> incorrectly paired by `show-paren-mode`. This is trivially >>>>> reproducible >>>>> with this simple example: >>>>> >>>>> (/foobar)/) >>>>> >>>>> The first parenthesis is matched with the second one, which is >>>>> inside a >>>>> regular expression pattern (between slashes), and the last one is not >>>>> paired. >>>>> >>>>> The behavior should be the same as for string, the content of the >>>>> regex >>>>> pattern should have no influence on the structure of the code. The >>>>> first >>>>> parenthesis should match with the third one. Here, the first >>>>> parenthesis >>>>> is matched with the last one: >>>>> >>>>> ("foobar)") >>>>> >>>>> js-mode behaves correctly in both cases. >>>> Sounds like js-ts-mode also needs a syntax-propertize-function, similar >>>> to c-ts-mode, ruby-ts-mode and rust-ts-mode. >>>> >>>> Others (typescript-ts-mode?) probably need it as well, at least modes >>>> for those languages that have dedicated regexp or heredoc syntax. >>> Would someone please add syntax-propertize-function in modes that need >>> it?  I think this should be done on the emacs-29 branch. >>> >>> TIA >> I'll add it to my list, but if someone will grab it that's fine, as I'm >> a little short on time the next couple of weeks 🙁 > > This one seems to work for js-ts-mode. > > typescript is a bit more fiddly (two separate modes, one with jsx and > one without), but should be able to follow the similar pattern. Thanks for the patch, but I still have some issues. I believe that the START and END arguments of `put-text-property` are off by one. The attached modified patch seems to work better. --------------1t7DedAiwq7MVMG8YRUu7fOa Content-Type: text/x-patch; charset=UTF-8; name="js-ts--syntax-propertize-v2.diff" Content-Disposition: attachment; filename="js-ts--syntax-propertize-v2.diff" Content-Transfer-Encoding: base64 ZGlmZiAtLWdpdCBhL2xpc3AvcHJvZ21vZGVzL2pzLmVsIGIvbGlzcC9wcm9nbW9kZXMvanMu ZWwKaW5kZXggOWQyOTkwZTdiYzkuLmE3NGY2N2Q0NDY2IDEwMDY0NAotLS0gYS9saXNwL3By b2dtb2Rlcy9qcy5lbAorKysgYi9saXNwL3Byb2dtb2Rlcy9qcy5lbApAQCAtMzgyOSw2ICsz ODI5LDcgQEAganMtdHMtbW9kZQogICAgICAgICAgICAgICAgIChhcHBlbmQgInt9KCk6Oyw8 Pi8iIGVsZWN0cmljLWluZGVudC1jaGFycykpIDtGSVhNRToganMyLW1vZGUgYWRkcyAiW10q Ii4KICAgICAoc2V0cS1sb2NhbCBlbGVjdHJpYy1sYXlvdXQ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G5hbWUgLiAsbm9kZSkgY2FwdHVyZXMpCisgICAgICAobGV0ICgoc3ludGF4IChwY2FzZS1l eGhhdXN0aXZlIG5hbWUKKyAgICAgICAgICAgICAgICAgICAgICAoJ3JlZ2V4cAorICAgICAg ICAgICAgICAgICAgICAgICAoc3RyaW5nLXRvLXN5bnRheCAiXCIvIikpCisgICAgICAgICAg ICAgICAgICAgICAgKCdqc3gKKyAgICAgICAgICAgICAgICAgICAgICAgKHN0cmluZy10by1z eW50YXggInwiKSkpKSkKKyAgICAgICAgKHB1dC10ZXh0LXByb3BlcnR5ICgxLSAodHJlZXNp dC1ub2RlLXN0YXJ0IG5vZGUpKSAodHJlZXNpdC1ub2RlLXN0YXJ0IG5vZGUpCisgICAgICAg ICAgICAgICAgICAgICAgICAgICAnc3ludGF4LXRhYmxlIHN5bnRheCkKKyAgICAgICAgKHB1 dC10ZXh0LXByb3BlcnR5ICh0cmVlc2l0LW5vZGUtZW5kIG5vZGUpICgxKyAodHJlZXNpdC1u b2RlLWVuZCBub2RlKSkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICdzeW50YXgtdGFi bGUgc3ludGF4KSkpKSkKKwogOzs7IyMjYXV0b2xvYWQKIChkZWZpbmUtZGVyaXZlZC1tb2Rl IGpzLWpzb24tbW9kZSBqcy1tb2RlICJKU09OIgogICAoc2V0cS1sb2NhbCBqcy1lbmFibGVk LWZyYW1ld29ya3MgbmlsKQo= --------------1t7DedAiwq7MVMG8YRUu7fOa--