Subject: bug#75217: 31.0.50; tsx-ts-mode has wonky text motions and indentation

From: Arsen Arsenović <[email-masked]>
Date: Sat, 11 Jan 2025 20:30:21 +0100

Juri Linkov <[email-masked]> writes:

>> 1. Insert the following into a tsx-ts-mode buffer:
>>
>> function F() {
>>   return (
>>     <H>Delete</H>
>>   );
>> }
>>
>> 2. Install tree-sitter-tsx v0.23.2
>> 3. M-x tsx-ts-mode RET
>> 3. M-: (goto-char 39) RET  (somewhere in the middle of "Delete")
>> 4. M-b
>> 5. Observe that point is not at the start of "Delete"
>
> This is fixed in bug#73978.

Yes, seems fixed now.

>> Following that, alter <H> to be <H foo="bar"> and hit RET at the start
>> of "Delete", at this point you should see:
>>
>> function F() {
>>   return (
>>     <H foo="bar">
>> 		   Delete</H>
>>   );
>> }
>>
>>
>> This is unusual.
>
> What indentation in your opinion would be correct?

A shift level extra compared to the opening < of the <H:

  function F() {
    return (
      <H foo="bar">
        Delete</H>
    );
  }

Currently, the indentation engine prefers:

  function F() {
    return (
      <H foo="bar">
                     Delete
      </H>
    );
  }

... which looks odd.

>> In addition, I just noticed one more thing; make a new file containing:
>>
>> function F() {
>>   return (
>>     <H>Delete</H>
>>   );
>> }
>>
>> Navigate to the start of "Delete", run M-x treesit-explore RET, hit RET
>> and tell the explorer to highlight the jsx_text corresponding to
>> "Delete", you should see that the region highlighted is not aligned with
>> the end of the word "Delete", and, in turn, all subsequent AST nodes are
>> mispositioned too.  Typing again fixes this issue.  It seems that the
>> buffer needs to be freshly-started for this to happen for some reason.
>>
>> I do not have any idea why this might be happening.
>
> I tried, but can't reproduce this treesit-explore issue.

Hmm, yes, seems that this went away also.  

That's great!  Thank you so much!
-- 
Arsen Arsenović