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

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

bug#61142: 回复: bug#61142: 29.0.60; java-ts-mode - Wrong indentation for


From: Theodor Thornhill
Subject: bug#61142: 回复: bug#61142: 29.0.60; java-ts-mode - Wrong indentation for the body of multiple lines conditions
Date: Sun, 05 Feb 2023 20:19:19 +0100

赵 纪阳 <zjyzhaojiyang@hotmail.com> writes:

> Thanks for the patch.
>

Thanks for testing!

> I've not tested this patch adequately, but I found an issue:
> java-ts-mode indents the body of `else if` with one more level of indentation.
>
> ```
> public class T {
>     int f() {
>         int a = 0;
>         int b = 1;
>         if (a == 0
>             && b == 1) {
>             // indentation ok
>             return 0;
>         } else if (a == 1 ) {
>                 // indentation more
>                 return 1;
>             }
>     }
> }
> ```
> If the second branch of the if-statement is just an `else` (not `else if`), 
> the body of it will be indented correctly.
>
>
> I've also tested c-ts-mode (use 'linux as c-ts-mode-indent-style) and it also 
> has this kind of problem.
> ```
> int main() {
>     int a = 0;
>     if (a == 0) {
>         // indentation ok
>     } else if (a == 2) {
>             // indentation more
>         }
> }
> ```
>

Right, I remember this.  This finally made me create a fix - can you
test the provided patch and check if this works for you?  It works
nicely for me, at least.

Theo

Attachment: 0001-Use-c-ts-common-statement-offset-in-java-ts-mode.patch
Description: Text Data


reply via email to

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