-
Notifications
You must be signed in to change notification settings - Fork 98
Description
The formatter considers the following as properly formatted:
(kotlinlang-style)
fun quux() =
runnnnn {
foo()
bar()
}
.baz()(Java-like)
fun quux() =
runnnnn {
foo()
bar()
}
.baz()It seems to be adding a continuation indentation to the ending brace and the content of the lambda
Is this intentional behaviour? It looks really strange to me, personally.
It happens without the single-expression body as well:
fun quux() {
runnnnn {
foo()
bar()
}
.baz()
}What I'd prefer instead is this:
fun quux() {
runnnnn {
foo()
bar()
}.baz()
}i.e. the ending brace should always have the same indentation as the starting brace, and thus the lambda should always have block indentation, and nothing more. For the .baz() call, I'm fine with whatever. It can be on a separate line, or the same line, or floating, or anything like that. I just dislike the idea that lambdas float in such a strange way.
For what it's worth, try-catch handles this elegantly IMO:
fun quux() {
try {
foo()
bar()
} catch (_: Throwable) {
foo()
bar()
}
}fun quux() {
try {
foo()
bar()
} catch (_: Throwable) {}
}and similarly with infix calls and operators:
fun quux() {
runnnnnn {
foo()
bar()
} + baz()
}fun quux() {
runnnnnn {
foo()
bar()
} inny baz()
}so I'd call this "precedent"