bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#65470: 29.1.50; js-ts-mode: regex pattern can cause incorrect parent


From: BTuin
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
User-agent: Mozilla Thunderbird

Le 25/08/2023 à 02:18, Dmitry Gutov a écrit :
On 24/08/2023 22:47, Theodor Thornhill wrote:
Eli Zaretskii<eliz@gnu.org>  writes:

Date: Wed, 23 Aug 2023 16:23:13 +0300
From: Dmitry Gutov<dmitry@gutov.dev>

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.

Attachment: js-ts--syntax-propertize-v2.diff
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]