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 21:12:23 +0100

Theodor Thornhill <theo@thornhill.no> writes:

> Eli Zaretskii <eliz@gnu.org> writes:
>
>>> Cc: "61142@debbugs.gnu.org" <61142@debbugs.gnu.org>
>>> Date: Sun, 05 Feb 2023 20:19:19 +0100
>>> From:  Theodor Thornhill via "Bug reports for GNU Emacs,
>>>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>>> 
>>> +(defvar c-ts-common-nestable-if-statement-p t
>>> +  "Does the current parser nest if-else statements?
>>> +
>>> +T if the current tree-sitter grammar nests the else if
>>> +statements, NIL otherwise.")
>>
>> A nit: we use t and nil, lowercase, to refer to these two symbols.
>>
>> Thanks.
>
> Thanks!
>
> Theo

I added some small tweaks, and will add the following as a test later:

```
public class Java {
    
    public Java(
        String foo) {
        this.foo = foo;
    }

    void foo(
        String foo) {

        for (var f : rs)
            return new String[]{
                "foo",
                "bar"
            };
        if (a == 0
            && b == 1
            && foo) {
            return 0;
        } else if (a == 1) {
            return 1;
        } else if (true)
            return 5;
        else {
            if (a == 0
                && b == 1
                && foo)
                while (true)
                    for (
                        ;;)
                        if (true)
                            return 5;
                        else if (false) {
                            return 6;
                        } else
                            if (true
                                && false)
                                return 6;
        }
    }
}
```

Even though its some pretty wild code, its indented correctly after this
patch.  I'll create something similar for C as well.

Theo

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


reply via email to

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