GNU bug report logs -
#75422
30.0.93; [PATCH] forward-sexp and backward-sexp jump outside of comments in tsx-ts-mode
Previous Next
Reported by: Kohei Tsuruta <seventhepg <at> gmail.com>
Date: Tue, 7 Jan 2025 16:03:01 UTC
Severity: normal
Tags: patch
Fixed in version 30.0.93
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
Message #11 received at 75422 <at> debbugs.gnu.org (full text, mbox):
> On Jan 7, 2025, at 9:44 AM, Juri Linkov <juri <at> linkov.net> wrote:
>
>> Steps to reproduce
>> - emacs -Q test.tsx
>> - (tsx-ts-mode)
>> - Move point at the end of the comment at line 3
>> - (backward-sexp)
>>
>> The expected point position after (backward-sexp) is "treesit-thing-|settings"
>> or at least stay inside of the comment line, however, point moves to the
>> beginning of "Hello".
>> Likewise, if you C-x C-e at the end of the comment line, it evaluates "Hello".
>>
>> --- test.tsx (| is point) ---
>> export const App = () => {
>> const greeting = "Hello"
>> // treesit-thing-settings|
>> return <>{greeting}</>
>> }
>> --- END test.tsx ---
>>
>> It happens because tsx-ts-mode doesn't recognize comments. In
>> typescript-ts-base-mode, treesit-thing-settings is set to have "text" as
>> a thing for typescript but it's missing in tsx-ts-mode when it's set for
>> tsx.
>
> Thanks for the report. This is fixed in Emacs 31.
>
> However, maybe Yuan will agree to add this small fix to Emacs 30?
>
>> diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el
>> index 4a38d1da596..0ffcb144771 100644
>> --- a/lisp/progmodes/typescript-ts-mode.el
>> +++ b/lisp/progmodes/typescript-ts-mode.el
>> @@ -564,7 +564,9 @@ tsx-ts-mode
>> (sentence ,(regexp-opt
>> (append typescript-ts-mode--sentence-nodes
>> '("jsx_element"
>> - "jsx_self_closing_element")))))))
>> + "jsx_self_closing_element"))))
>> + (text ,(regexp-opt '("comment"
>> + "template_string"))))))
I think it’s fine. Though it’s for Eli to decide.
Yuan
This bug report was last modified 189 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.