Reputation: 997
We have some trouble with how the code formatting works when returning after a method parameters call that is not correctly aligned with the above )
. In AndroidStudio 3.2.1 currently but it was doing that for as far I can remember. The problem is happening in Kotlin and Java.
What the AutoFormat does that we don't like.
fun behaviourExample() {
this.methodCall(
lambda1 = { /*something*/ },
lambda2 = { /*somethingElse*/ }
)
.map { "Line incorrectly indented" }
.map { "I'd like the lines to be correctly indented" }
}
fun methodCall(lambda1: () -> Unit, lambda2: () -> Unit): String {
return "otherThing"
}
We would like to find the parameters to change the AutoFormat like this: map{}
correctly aligned with the closing )
fun behaviourExample() {
this.methodCall(
lambda1 = { /*something*/ },
lambda2 = { /*somethingElse*/ }
)
.map { "Line correctly indented" }
.map { "I'd like the lines to be correctly indented" }
}
What we are doing in the meanwhile is to return before the methodCall
, that's not pretty but that works.
fun behaviourExample() {
this
.methodCall(
lambda1 = { /*something*/ },
lambda2 = { /*somethingElse*/ }
)
.map { "Line correctly indented but I don't like to be forced to add methodCall() in a new line" }
.map { "I'd like the lines to be correctly indented" }
}
We suspect that it should be somewhere in the preferences -> Code Style -> Kotlin but we played with a bunch of parameters and didn't found it
Above is an example of how the autoformat behaves but our problem is with calls like Single.zip()
, Observable.concat()
etc... The indentation misleads where in the chain you can be. So we use it like this.
Single
.zip (
/* parameters */
)
.map { /* something */ }
Instead of
Single.zip (
/* parameters */
)
.map { /* something */ }
Thanks for any help or leads.
Upvotes: 2
Views: 2544
Reputation: 97308
The formatting you're using now is actually how such code is supposed to be formatted according to the coding conventions. If the closing parenthesis of a method call is wrapped to a new line, it's aligned with the beginning of the method call. There is no option to indent it by 4 spaces.
Upvotes: 2