diff --git a/ktlint-ruleset-experimental/src/main/kotlin/com/pinterest/ktlint/ruleset/experimental/IndentationRule.kt b/ktlint-ruleset-experimental/src/main/kotlin/com/pinterest/ktlint/ruleset/experimental/IndentationRule.kt index 297ab4cbcf..8e5a0db6e3 100644 --- a/ktlint-ruleset-experimental/src/main/kotlin/com/pinterest/ktlint/ruleset/experimental/IndentationRule.kt +++ b/ktlint-ruleset-experimental/src/main/kotlin/com/pinterest/ktlint/ruleset/experimental/IndentationRule.kt @@ -363,6 +363,9 @@ class IndentationRule : Rule("indent"), Rule.Modifier.RestrictToRootLast { val lf = rToken?.nextLeaf { it.isWhiteSpaceWithNewline() } return lf?.parent({ it == p }) == null } + if (nextCodeSibling?.textContains('\n') == false) { + return true + } return false } diff --git a/ktlint-ruleset-experimental/src/test/resources/spec/indent/format-arrow-expected.kt.spec b/ktlint-ruleset-experimental/src/test/resources/spec/indent/format-arrow-expected.kt.spec index a3ba11cc63..5a406978d0 100644 --- a/ktlint-ruleset-experimental/src/test/resources/spec/indent/format-arrow-expected.kt.spec +++ b/ktlint-ruleset-experimental/src/test/resources/spec/indent/format-arrow-expected.kt.spec @@ -23,6 +23,10 @@ fun main() { 2 // second element -> true } + when { + 1, + 2 -> true + } foo.func { param1, param2 -> doSomething() diff --git a/ktlint-ruleset-experimental/src/test/resources/spec/indent/format-arrow.kt.spec b/ktlint-ruleset-experimental/src/test/resources/spec/indent/format-arrow.kt.spec index ac87b97fc2..af6034cf0d 100644 --- a/ktlint-ruleset-experimental/src/test/resources/spec/indent/format-arrow.kt.spec +++ b/ktlint-ruleset-experimental/src/test/resources/spec/indent/format-arrow.kt.spec @@ -20,6 +20,10 @@ fun main() { 2 // second element -> true } + when { + 1, + 2 -> true + } foo.func { param1, param2 -> doSomething()