Subject: Re: bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter

From: Yuan Fu <[email-masked]>
Date: Fri, 24 Mar 2023 11:17:28 -0700

"Herman, Geza" <[email-masked]> writes:

> Copy this half-written program to a c++-ts-mode buffer:
>
> ----- 8< -----------------------
>
> void foo() {
>   for (int i=0
> }
>
> int main(int argc, char *argv[]) {
> }
>
> ----- 8< -----------------------
>
> Move the point to the end of the line of the for loop, and press ";"
> (as if you continued to write the loop). Notice that the line will
> lose its indentation ("for" will be moved to column 1). If you
> continue writing the for loop, it will be correctly re-indented after
> the closing parenthesis (for example, continue the line with "; i<10;
> i++)", and notice that after pressing ")", the line will be
> re-indented).
>
> This doesn't happen if the main function is deleted. I'm not sure
> whether this is a tree-sitter or emacs problem, but I reported here
> because I think it's more likely that this is some emacs problem.

I believe this is due to this rule:

((query "(ERROR (ERROR)) @indent") column-0 0)

I’m not sure about the original purpose for this rule, CC’ing Theo.

Yuan