ktlint
ktlint copied to clipboard
Continuation indent missing on lines after index expression
Expected Behavior
val a1 = a
.aList[0].let {
a // <---
}
Observed Behavior
val a1 = a
.aList[0].let {
a // <---
}
Steps to Reproduce
class A(val a: A? = null) {
val aList = listOf(this)
}
fun main() {
val a = A(A(A()))
val a1 = a
.aList[0].let {
a // <--- Oh, no!
}
val a2 = a
.a.let {
a // <--- The above should be like this.
}
}
Your Environment
- Version of ktlint used:
0.46.1 - Relevant parts of the
.editorconfigsettings: none - Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task):
id("com.diffplug.spotless") version "6.8.0"
Related
- The IntelliJ IDEA formatter behaves alike. The issue has been reported as https://youtrack.jetbrains.com/issue/KTIJ-22206.
Tnx for taking the effort to raise an issue and including the reference to the IntelliJ issue.
I agree with you that the indenting of bot ktlint and IntelliJ IDEA default formatter is not correct in the case above. This can however not be fixed in ktlint until it is resolved in IntellI IDEA default formatter as well. Other wise it would result in a conflict between ktlint and the IDEA formatter which we currently still try to prevent (see discussion #1526).