bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Yuan Fu
Subject: bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter
Date: Fri, 24 Mar 2023 11:17:28 -0700

"Herman, Geza" <geza.herman@gmail.com> 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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]