GNU bug report logs -
#73978
31.0.50; Text syntax applied on too many things in tsx-ts-mode
Previous Next
Reported by: Yuan Fu <casouri <at> gmail.com>
Date: Thu, 24 Oct 2024 04:08:02 UTC
Severity: normal
Found in version 31.0.50
Done: Yuan Fu <casouri <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your message dated Thu, 12 Dec 2024 21:47:41 -0800
with message-id <F3C21F12-3FB6-41EB-BED1-C6AF35EF5819 <at> gmail.com>
and subject line Re: bug#73978: 31.0.50; Text syntax applied on too many things in tsx-ts-mode
has caused the debbugs.gnu.org bug report #73978,
regarding 31.0.50; Text syntax applied on too many things in tsx-ts-mode
to be marked as done.
(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)
--
73978: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=73978
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
X-Debbugs-CC: theo <at> thornhill.no
In tsx-ts-mode we use this query to apply syntax properties:
(defvar tsx-ts--s-p-query
(when (treesit-available-p)
(treesit-query-compile 'tsx
'(((regex pattern: (regex_pattern) @regexp))
((variable_declarator value: (jsx_element) @jsx))
((assignment_expression right: (jsx_element) @jsx))
((arguments (jsx_element) @jsx))
((parenthesized_expression (jsx_element) @jsx))
((return_statement (jsx_element) @jsx))))))
And then in tsx-ts--syntax-propertize-captures we mark everything
enclosed by the captured jsx_element nodes in text fences.
Then for the following code
<button onClick={() => {
func();
return true;
}}>
Text
{func();}
</button>
All the func() and other code will be considered text because the whole
jsx tag (<button>...</button>) are wrapped in string fences. Theo,
what’s the original intention for marking jsx_elements as text? Can we
only mark jsx_text as string?
Yuan
[Message part 3 (message/rfc822, inline)]
> On Dec 12, 2024, at 9:19 AM, Dmitry Gutov <dmitry <at> gutov.dev> wrote:
>
> On 12/12/2024 06:56, Yuan Fu wrote:
>> How hard is it to add a new syntax for this case? Or is there some way to work around this? We can’t just not apply the string syntax, because if the “a” is a parenthesis, etc, it would mess up the parenthesis balancing after it.
>
> Probably not very hard, but that seems like it'd affect the total set of syntax classes - which means adding it to the manual, etc.
>
>> Maybe just give it a whitespace syntax?
>
> Right, in such cases I applied the "whitespace" or "punctuation" syntax to the whole character span, like in https://github.com/dgutov/mmm-mode/blob/master/mmm-erb.el#L97
Thanks. I went with the whitespace trick and pushed my patch to master.
Yuan
This bug report was last modified 133 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.