GNU bug report logs -
#72263
31.0.50; Wrong indentation c++-ts-mode
Previous Next
Reported by: Ergus <spacibba <at> aol.com>
Date: Wed, 24 Jul 2024 00:03:02 UTC
Severity: normal
Found in version 31.0.50
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Pushed a fix for the original bug to emacs-30. Now it indents like this:
namespace A {
T myfunction1(const char *fname)
{
}
template <class T>
T myfunction2(const char *fname)
{
}
}
> On Jul 31, 2024, at 10:06 PM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>
>> Date: Wed, 31 Jul 2024 23:09:53 +0200
>> From: Ergus <spacibba <at> aol.com>
>> CC: 72263 <at> debbugs.gnu.org
>>
>> I found another indentation issue in if-else conditions without
>> parenthesis:
>>
>> if (pid == 0)
>> print "hello from the child"
>> else
>> print "hello from the parent"
>>
>> The else is not indented properly:
>
> The above is not valid C++ code, AFAIU, so I don't understand why you
> expect c++-ts-mode to handle it properly (and what exactly is "proper"
> indentation in that case?).
As Eli said, if you add the trailing semicolon then it indents fine. If the code isn’t grammatically correct it’s hard for tree-sitter modes to indent the code.
Yuan
This bug report was last modified 337 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.