GNU bug report logs - #61026
29.0.60; c-ts-mode: Broken indentation for loops and conditions without brace

Previous Next

Package: emacs;

Reported by: Mohammed Sadiq <sadiq <at> sadiqpk.org>

Date: Mon, 23 Jan 2023 11:18:02 UTC

Severity: normal

Found in version 29.0.60

Full log


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

From: Yuan Fu <casouri <at> gmail.com>
To: Theodor Thornhill <theo <at> thornhill.no>
Cc: Mohammed Sadiq <sadiq <at> sadiqpk.org>, 61026 <at> debbugs.gnu.org
Subject: Re: bug#61026: 29.0.60; c-ts-mode: Broken indentation for loops and 
 conditions without brace
Date: Sun, 29 Jan 2023 00:22:26 -0800
Theodor Thornhill <theo <at> thornhill.no> writes:

> Yuan Fu <casouri <at> gmail.com> writes:
>
>> Theodor Thornhill <theo <at> thornhill.no> writes:
>>
>>> Mohammed Sadiq <sadiq <at> sadiqpk.org> writes:
>>>
>>>> The following code has broken indentation with c-ts-mode:
>>>>
>>>>   while (true)
>>>>     if (true) {
>>>>     puts ("Hello");
>>>>   }
>>>>
>>>>   if (true)
>>>>     if (true)
>>>>       {
>>>>       puts ("World");
>>>>     }
>>>>
>>>> For which, I expect to get the following indentation (with default config):
>>>>
>>>>   while (true)
>>>>     if (true) {
>>>>       puts ("Hello");
>>>>     }
>>>>
>>>>   if (true)
>>>>     if (true)
>>>>       {
>>>>         puts ("World");
>>>>       }
>>>>
>>>>
>>>
>>> Thanks, Mohammed!
>>>
>>> Yuan, I'm not sure the new brace counting method is a good enough
>>> improvement just yet considering its complexity and the number of issues
>>> we are seeing.  Do you see any simple fixes for these issues?
>>
>> I fixed it.
>>
>>> I can try to debug this this weekend, but not sure I really have time to
>>> fix it.  All of these issues work fine in js-ts-mode or java-ts-mode, if
>>> I'm not mistaken.
>>
>> Yes, because js and java doesn’t allow omitting brackets. So we only
>> need to add a special-case for C/C++, so it isn’t too bad.
>>
>> Yuan
>
> They allow that just fine, don't they? 

You are right. I made the fix general and moved everything to
c-ts-common.el. The next step is to make other modes use it.

Yuan




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

Previous Next


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