Stop unwrapping wrapped function chaining
Using version 0.44.
Initial
fun main() {
return StringBuilder()
.append("Stop ")
.append("making this ")
.append("one line")
.toString()
}
After formatting
fun main() {
return StringBuilder().append("Stop ").append("making this ").append("one line").toString()
}
I would expect ktfmt to leave this section alone. The kotlinlang style guide doesn't say that you should or should not use wrapped function chaining, but if you are you should follow these guidelines:
https://kotlinlang.org/docs/coding-conventions.html#wrap-chained-calls
Whenever something like this happens, I use a dummy // force br line comment to prevent this behavior.
fun main() {
return StringBuilder() // force br
.append("Stop ")
.append("making this ")
.append("one line")
.toString()
}
This is not something we plan to work on as one of the ideas of ktfmt is that spaces and new lines would not influence the output of the formatter. This is not fully obeyed as we do preserve some empty new lines, but for this particular case we don't plan to make an exception.
You're welcome to submit a PR for this though, I'd gladly review it and personally I also like this suggestion