Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Incorrect indentation with multi-line conditions #959

Closed
ajeihala opened this issue Nov 11, 2020 · 0 comments · Fixed by #985
Closed

Incorrect indentation with multi-line conditions #959

ajeihala opened this issue Nov 11, 2020 · 0 comments · Fixed by #985
Labels

Comments

@ajeihala
Copy link

Seems there's an issue with formatter (version 0.39.0).

In this artificial code example IDEA (Android Studio) formats it as:

fun test() {
    val result = true &&
        minOf(
            1, 2
        ) == 2 // this line
}

which looks correct.

But ktlint formats it as

fun test() {
    val result = true &&
        minOf(
            1, 2
    ) == 2 // this line
}

(notice, the ) == 2 line is aligned with the whole val and not its method minOf.

The key difference is comparison == 2, which breaks the formatting, because ktlint formats it correctly for a similar case with no final comparison:

fun test() {
    val result = true &&
        checkNotNull(
            true,
            { "test" }
        ) // this line
}
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
2 participants