GNU bug report logs - #73376
Treesitter does not rescan after indentation

Previous Next

Package: emacs;

Reported by: pranshu sharma <pranshusharma366 <at> gmail.com>

Date: Fri, 20 Sep 2024 07:02:01 UTC

Severity: normal

Done: Yuan Fu <casouri <at> gmail.com>

To reply to this bug, email your comments to 73376 AT debbugs.gnu.org.
There is no need to reopen the bug first.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#73376; Package emacs. (Fri, 20 Sep 2024 07:02:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to pranshu sharma <pranshusharma366 <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 20 Sep 2024 07:02:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: pranshu sharma <pranshusharma366 <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Treesitter does not rescan after indentation
Date: Fri, 20 Sep 2024 17:00:39 +1000
After indenting, treesitter does not rescan the region.  This causes
errors in the concrete syntax tree, which mess up indentation and syntax
colouring.

The issue I'm having is kind of hard to explain, but in a summary I have
the poorly indented code, where what's between '_'(which is not in the
code itself) is coloured:
---------------
f x =
               let _a_ = 2
                   _c_ = 1
  in a
--------------
Then when I indent it with haskell-ts-mode, I get:
---------------
f x =
  let _a_ = 2
      c = 1
  in a
--------------
When the 2 snippets of code have the exact same meaning.  If I revert
the buffer then the 'c' becomes coloured again.

This is not just problem with syntax highlighting, but if I was to
indent the 2nd snippet it would mess it up, as it has the wrong CST.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#73376; Package emacs. (Sat, 21 Sep 2024 04:23:02 GMT) Full text and rfc822 format available.

Message #8 received at 73376 <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: pranshu sharma <pranshusharma366 <at> gmail.com>
Cc: 73376 <at> debbugs.gnu.org
Subject: Re: bug#73376: Treesitter does not rescan after indentation
Date: Fri, 20 Sep 2024 21:20:49 -0700

> On Sep 20, 2024, at 12:00 AM, pranshu sharma <pranshusharma366 <at> gmail.com> wrote:
> 
> 
> After indenting, treesitter does not rescan the region.  This causes
> errors in the concrete syntax tree, which mess up indentation and syntax
> colouring.
> 
> The issue I'm having is kind of hard to explain, but in a summary I have
> the poorly indented code, where what's between '_'(which is not in the
> code itself) is coloured:
> ---------------
> f x =
>               let _a_ = 2
>                   _c_ = 1
>  in a
> --------------
> Then when I indent it with haskell-ts-mode, I get:
> ---------------
> f x =
>  let _a_ = 2
>      c = 1
>  in a
> --------------
> When the 2 snippets of code have the exact same meaning.  If I revert
> the buffer then the 'c' becomes coloured again.
> 
> This is not just problem with syntax highlighting, but if I was to
> indent the 2nd snippet it would mess it up, as it has the wrong CST.
> 

Hi Pranshu,

Thanks for the report. I can reproduce it. Let me see what’s going on here.

Yuan



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#73376; Package emacs. (Sun, 22 Sep 2024 06:38:02 GMT) Full text and rfc822 format available.

Message #11 received at 73376 <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: pranshu sharma <pranshusharma366 <at> gmail.com>
Cc: 73376 <at> debbugs.gnu.org
Subject: Re: bug#73376: Treesitter does not rescan after indentation
Date: Sat, 21 Sep 2024 23:35:50 -0700

> On Sep 20, 2024, at 9:20 PM, Yuan Fu <casouri <at> gmail.com> wrote:
> 
> 
> 
>> On Sep 20, 2024, at 12:00 AM, pranshu sharma <pranshusharma366 <at> gmail.com> wrote:
>> 
>> 
>> After indenting, treesitter does not rescan the region.  This causes
>> errors in the concrete syntax tree, which mess up indentation and syntax
>> colouring.
>> 
>> The issue I'm having is kind of hard to explain, but in a summary I have
>> the poorly indented code, where what's between '_'(which is not in the
>> code itself) is coloured:
>> ---------------
>> f x =
>>              let _a_ = 2
>>                  _c_ = 1
>> in a
>> --------------
>> Then when I indent it with haskell-ts-mode, I get:
>> ---------------
>> f x =
>> let _a_ = 2
>>     c = 1
>> in a
>> --------------
>> When the 2 snippets of code have the exact same meaning.  If I revert
>> the buffer then the 'c' becomes coloured again.
>> 
>> This is not just problem with syntax highlighting, but if I was to
>> indent the 2nd snippet it would mess it up, as it has the wrong CST.
>> 
> 
> Hi Pranshu,
> 
> Thanks for the report. I can reproduce it. Let me see what’s going on here.
> 
> Yuan

Seems to be a tree-sitter or tree-sitter-haskell bug, reported here: https://github.com/tree-sitter/tree-sitter-haskell/issues/129

Yuan



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#73376; Package emacs. (Mon, 23 Sep 2024 13:11:02 GMT) Full text and rfc822 format available.

Message #14 received at 73376 <at> debbugs.gnu.org (full text, mbox):

From: pranshu sharma <pranshusharma366 <at> gmail.com>
To: Yuan Fu <casouri <at> gmail.com>
Cc: 73376 <at> debbugs.gnu.org
Subject: Re: bug#73376: Treesitter does not rescan after indentation
Date: Mon, 23 Sep 2024 23:08:33 +1000
Ok, keep us updated if any progress is made




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#73376; Package emacs. (Mon, 26 May 2025 04:01:02 GMT) Full text and rfc822 format available.

Message #17 received at 73376 <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: pranshu sharma <pranshusharma366 <at> gmail.com>
Cc: 73376 <at> debbugs.gnu.org
Subject: Re: bug#73376: Treesitter does not rescan after indentation
Date: Sun, 25 May 2025 21:00:19 -0700

> On Sep 23, 2024, at 6:08 AM, pranshu sharma <pranshusharma366 <at> gmail.com> wrote:
> 
> 
> Ok, keep us updated if any progress is made

I later reported the bug to tree-sitter repo. There tree-sitter devs explained that it’s because Emacs wasn’t reporting line & column positions to tree-sitter. Since then I added line & column tracking and reporting for tree-sitter, and enabled it by default in Emacs. The bug doesn’t happen on mater now. Please see if this is fixed for you too.

Yuan



Reply sent to Yuan Fu <casouri <at> gmail.com>:
You have taken responsibility. (Mon, 26 May 2025 22:48:02 GMT) Full text and rfc822 format available.

Notification sent to pranshu sharma <pranshusharma366 <at> gmail.com>:
bug acknowledged by developer. (Mon, 26 May 2025 22:48:02 GMT) Full text and rfc822 format available.

Message #22 received at 73376-done <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Pranshu <pranshusharma366 <at> gmail.com>
Cc: 73376-done <at> debbugs.gnu.org
Subject: Re: bug#73376: Treesitter does not rescan after indentation
Date: Mon, 26 May 2025 15:47:08 -0700

> On May 25, 2025, at 10:57 PM, Pranshu <pranshusharma366 <at> gmail.com> wrote:
> 
> It's fixed now, thanks!

Great! Closing.

Yuan



This bug report was last modified 27 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.