unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Yuan Fu <casouri@gmail.com>
To: Juri Linkov <juri@linkov.net>
Cc: Dmitry Gutov <dmitry@gutov.dev>,
	Theodor Thornhill <theo@thornhill.no>,
	73978@debbugs.gnu.org
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	[thread overview]
Message-ID: <5626DFE7-CA89-4A39-A896-99D8814FD6CD@gmail.com> (raw)
In-Reply-To: <87ed1xkn7h.fsf@mail.linkov.net>



> 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




  reply	other threads:[~2024-12-24 20:57 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-24  4:06 bug#73978: 31.0.50; Text syntax applied on too many things in tsx-ts-mode Yuan Fu
2024-11-09  9:11 ` Eli Zaretskii
2024-11-09 16:49   ` Yuan Fu
2024-11-23 12:15     ` Eli Zaretskii
2024-11-24  5:25       ` Yuan Fu
2024-11-24  7:47         ` Eli Zaretskii
2024-11-24 13:45           ` Dmitry Gutov
2024-11-25  1:27             ` Yuan Fu
2024-12-11  4:52               ` Yuan Fu
2024-12-12  2:52                 ` Dmitry Gutov
2024-12-12  4:56                   ` Yuan Fu
2024-12-12 17:19                     ` Dmitry Gutov
2024-12-13  5:47                       ` Yuan Fu
2024-12-24  7:59 ` Juri Linkov
2024-12-24  8:31   ` Juri Linkov
2024-12-24  8:52     ` Yuan Fu
2024-12-24 17:25       ` Juri Linkov
2024-12-24 20:57         ` Yuan Fu [this message]
2024-12-25  7:40           ` Juri Linkov
2024-12-25  8:33             ` Yuan Fu
2024-12-26  5:37               ` Dmitry Gutov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5626DFE7-CA89-4A39-A896-99D8814FD6CD@gmail.com \
    --to=casouri@gmail.com \
    --cc=73978@debbugs.gnu.org \
    --cc=dmitry@gutov.dev \
    --cc=juri@linkov.net \
    --cc=theo@thornhill.no \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).