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: Jostein Kjønigsen
Subject: bug#65470: 29.1.50; js-ts-mode: regex pattern can cause incorrect parenthesis matching
Date: Fri, 15 Sep 2023 14:11:12 +0200

> On 13 Sep 2023, at 01:14, Dmitry Gutov <dmitry@gutov.dev> wrote:
> 
> On 12/09/2023 09:29, Jostein Kjønigsen wrote:
>> Good feedback. I’ve tested and included those as well. Attached is a new 
>> patch.
> 
> Thanks! Installed. It would've been better with a commit message too (next 
> time).
> 
> Speaking of the TSX difficulties, though, which Yuan hinted at recently: I 
> think the current fix (tsx-ts-mode--font-lock-compatibility-bb1f97b) is not 
> working. To be clear, that's unrelated to the current patch.
> 
> Basically, the query for ((member_expression) @capture) succeeds, but then 
> the more complex one fails with
> 
> Structure error at: 22
> (jsx_opening_element [(member_expression (identifier)) (identifier)] 
> @typescript-ts-jsx-tag-face) (jsx_closing_element [(member_expression 
> (identifier)) (identifier)] @typescript-ts-jsx-tag-face) 
> (jsx_self_closing_element [(member_expression (identifier)) (identifier)] 
> @typescript-ts-jsx-tag-face)
> 
> This patch seems to fix that and bring JSX syntax highlighting back:
> 
> diff --git a/lisp/progmodes/typescript-ts-mode.el 
> b/lisp/progmodes/typescript-ts-mode.el
> index 57382c9cb31..7108ff49b28 100644
> --- a/lisp/progmodes/typescript-ts-mode.el
> +++ b/lisp/progmodes/typescript-ts-mode.el
> @@ -163,7 +163,7 @@ tsx-ts-mode--font-lock-compatibility-bb1f97b
>   ;; but then raises an error if the wrong node type is used. So it is
>   ;; important to check with the new node type (member_expression)
>   (condition-case nil
> -      (progn (treesit-query-capture language '((member_expression) @capture))
> +      (progn (treesit-query-capture language '(jsx_opening_element 
> (member_expression) @capture))
>            '((jsx_opening_element
>               [(member_expression (identifier)) (identifier)]
>               @typescript-ts-jsx-tag-face)
> 

I really don’t know this part of the code very well. If you’ve identified an 
issue/bug for a specific TSX use-case, and found a fix for it, I have no 
objections to it being applied.

—
Jostein






reply via email to

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