[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#73978: 31.0.50; Text syntax applied on too many things in tsx-ts-mod
From: |
Yuan Fu |
Subject: |
bug#73978: 31.0.50; Text syntax applied on too many things in tsx-ts-mode |
Date: |
Tue, 24 Dec 2024 12:57:15 -0800 |
> On Dec 24, 2024, at 9:25 AM, Juri Linkov <juri@linkov.net> wrote:
>
>>> @@ -630,7 +640,8 @@ tsx-ts--s-p-query
>>> (when (treesit-available-p)
>>> (treesit-query-compile 'tsx
>>> '(((regex pattern: (regex_pattern) @regexp))
>>> - ((jsx_text) @jsx)))))
>>> + ((jsx_opening_element) @jsx)
>>> + ((jsx_closing_element) @jsx)))))
>>>
>>> (defun typescript-ts--syntax-propertize (beg end)
>>> (let ((captures (treesit-query-capture 'typescript
>>> typescript-ts--s-p-query beg end)))
>>
>> Thanks for looking into this! But what’s the intention of this change?
>> In a snippet like this:
>>
>> <button onClick={() => {
>> func();
>> return true;
>> }}>
>> Text
>> {func();}
>> </button>
>>
>> Only the “Text” part should be marked as string. With the change you
>> proposed, the <button …> and </button> part would be marked as string.
>
> How could I see that text is marked as string?
> I see no different fontification.
It’s marked as string for syntax-ppss purpose, so that syntax-ppss skips it
when scanning for balanced pairs. It’s not related to fontification.
>
>> We must mark text as strings because they could include </>/(/) etc
>> and mess with syntax-ppss.
>
> With the updates in 'tsx-ts-mode' that I just pushed to master
> please try in the following example:
>
> ReactDOM.render(
> <div>
> <h1>Hello, Welcome to React and TypeScript</h1>
> </div>,
> document.getElementById("root")
> );
>
> 1. move point to the beginning of <h1>
> 2. type C-M-b
> 3. point incorrectly moves to inside <div>
>
> However, this the above patch, point doesn't move
> that is correct.
>
> Another test case:
>
> 1. move point to the beginning of the word "Welcome"
> 2. type C-M-b
> 3. point incorrectly moves to the letter "e" instead of correct "H"
>
> 4. type C-M-f a few times until the end of text
> 5. point stops at the letter "t" instead of moving after the last letter
>
> All these cases work correctly with the patch above.
I understand the problem you want to solve, but the patch above will bring back
the bug I was trying to fix in the first place.
And I still don’t understand the intention of your patch. Maybe I missed
something. Am I correct that you want to apply string syntax on the tags, eg,
<div>, <button>, </button>, </div>?
Yuan
- bug#73978: 31.0.50; Text syntax applied on too many things in tsx-ts-mode, Juri Linkov, 2024/12/24
- bug#73978: 31.0.50; Text syntax applied on too many things in tsx-ts-mode, Juri Linkov, 2024/12/24
- bug#73978: 31.0.50; Text syntax applied on too many things in tsx-ts-mode, Yuan Fu, 2024/12/24
- bug#73978: 31.0.50; Text syntax applied on too many things in tsx-ts-mode, Juri Linkov, 2024/12/24
- bug#73978: 31.0.50; Text syntax applied on too many things in tsx-ts-mode,
Yuan Fu <=
- bug#73978: 31.0.50; Text syntax applied on too many things in tsx-ts-mode, Juri Linkov, 2024/12/25
- bug#73978: 31.0.50; Text syntax applied on too many things in tsx-ts-mode, Yuan Fu, 2024/12/25
- bug#73978: 31.0.50; Text syntax applied on too many things in tsx-ts-mode, Dmitry Gutov, 2024/12/26