diff --git a/ktlint-ruleset-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/IndentationRule.kt b/ktlint-ruleset-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/IndentationRule.kt index e708dd33e3..a6c9a81175 100644 --- a/ktlint-ruleset-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/IndentationRule.kt +++ b/ktlint-ruleset-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/IndentationRule.kt @@ -574,7 +574,9 @@ class IndentationRule : Rule("indent"), Rule.Modifier.RestrictToRootLast { adjustExpectedIndentAfterColon(n, ctx) prevLeaf?.elementType == LPAR && p.elementType == VALUE_ARGUMENT_LIST && - p.isPartOf(CONDITION) -> + p.parent(CONDITION, strict = false)?.takeIf { + it.prevLeaf()?.isWhiteSpaceWithNewline() != true + } != null -> // if (condition( // params // ) diff --git a/ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/IndentationRuleTest.kt b/ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/IndentationRuleTest.kt index b22f5f0d5f..951a9afa72 100644 --- a/ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/IndentationRuleTest.kt +++ b/ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/IndentationRuleTest.kt @@ -569,4 +569,27 @@ internal class IndentationRuleTest { """.trimIndent() assertThat(IndentationRule().format(code)).isEqualTo(code) } + + @Test + fun `lint if-condition with line break and multiline call expression is indented properly`() { + assertThat( + IndentationRule().lint( + """ + fun function(param1: Int, param2: Int, param3: Int?): Boolean { + return if ( + listOf( + param1, + param2, + param3 + ).none { it != null } + ) { + true + } else { + false + } + } + """.trimIndent() + ) + ).isEmpty() + } }