GNU bug report logs - #59686
30.0.50; tree-sitter indentation in some loops and conditional statements is wrong

Previous Next

Package: emacs;

Reported by: Bruce Stephens <bruce.stephens <at> isode.com>

Date: Tue, 29 Nov 2022 18:42:01 UTC

Severity: normal

Merged with 60398, 60496

Found in versions 29.0.60, 30.0.50

Full log


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

From: Theodor Thornhill <theo <at> thornhill.no>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: bruce.stephens <at> isode.com, casouri <at> gmail.com, 59686 <at> debbugs.gnu.org
Subject: Re: bug#59686: 30.0.50; tree-sitter indentation in some loops and
 conditional statements is wrong
Date: Fri, 02 Dec 2022 10:20:39 +0100
Eli Zaretskii <eliz <at> gnu.org> writes:

>> Cc: 59686 <at> debbugs.gnu.org
>> Date: Fri, 02 Dec 2022 06:42:03 +0100
>> From:  Theodor Thornhill via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>> 
>> >> // -*- c-ts -*-
>> >> int main() {
>> >>    for (int i=0; i<10; ++i) {
>> >>      foo(i);
>> >>    }
>> >>
>> >>    for (int i=0;
>> >>           i<10;
>> >>           ++i) {
>> >>             foo(i);
>> >>           }
>> >> }
>> >
>> >I see, that’s because the indent rule finds the BOL of the line where
>> >the "{" is on, and indents from there.  Theo, WDYT? Does indent style 
>> >fix this, or we should change the indent rules?
>> >
>> >Yuan
>> 
>> I've seen this issue myself, and have tried several combinations to fix it. It is trivial to fix this particular case, but because compound_statement is used everywhere problems will pop up other places. The fix here would be some grand-parent-bol function, but if my memory serves that would mess up the else in an if else. I'm happy to see this fixed, but just remember that it's not _super_ trivial.
>> 
>> Other languages exhibit similar issues, but with other constructs.
>
> FWIW, this is an unusual style, so I see no catastrophe if it is not 110%
> according to expectations.  Users can easily fix that by tweaking their BOLs
> where important.

Yeah, that was my reasoning as well.  I think we should come up with
some preset that can do this, but maybe when we know even more about how
to deal with similar edge cases?




This bug report was last modified 2 years and 209 days ago.

Previous Next


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