GNU bug report logs -
#66988
30.0.50; treesit-forward-sexp not working properly in js-ts-mode and tsx-ts-mode
Previous Next
Reported by: Loïc Lemaître <loic.lemaitre <at> gmail.com>
Date: Tue, 7 Nov 2023 16:20:01 UTC
Severity: normal
Found in version 30.0.50
Fixed in version 30.1
Done: Yuan Fu <casouri <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
> On Nov 9, 2023, at 5:41 PM, Dmitry Gutov <dmitry <at> gutov.dev> wrote:
>
> Hi!
>
> On 07/11/2023 16:56, Loïc Lemaître wrote:
>> Hi Emacs team,
>> Here the steps to demonstrate the bug :
>> 1. Compile Emacs from master branch with tree-sitter support
>> 2. Install javascript and tsx languages
>> 3. Run Emacs
>> 4. Create a new buffer
>> 5. Turn major mode to either js-ts-mode or tsx-ts-mode
>> 6. Past the following content into the buffer:
>> (
>> <div>
>> </div>
>> );
>> 7. Place point before opening parenthese
>> 8. M-x forward-sexp (which will call treesit-forward-sexp)
>> => New position is right after the semi-colon instead of being before the semi-colon.
>> Note that the bug disappear if the buffer content is changed for :
>> const component = (
>> <div>
>> </div>
>> );
>> But previous content, while not being very usefull, is valid JSX, as far as I know.
>> I use this syntax for unit test purpose, since it is very short.
>
> Thanks for the report.
>
> The patch below should fix it.
>
> Yuan, what do you think? A similar change (bos and eos anchors) might be useful for other things and other modes.
>
> Alternatively, treesit-thing-settings could be interpreted to imply full matches, then the code using it should not only match against the regexps but also check that the entire string (type name) is matched.
I regret not doing this by default for treesit-indent-rules and traverse functions. Now it’s hard to change without creating confusion and breaking backward compatibility. I wonder if there are good way to smoothly transition to match full names by default…
Treesit-thing-settings can be changed to match full names, but only if we can change treesit-indent-rules and friends too. Otherwise it would be too confusing.
Yuan
This bug report was last modified 1 year and 127 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.