Skip to content

Commit

Permalink
Fix indent when property value is wrapped
Browse files Browse the repository at this point in the history
Closes #2095
  • Loading branch information
paul-dingemans committed Jun 28, 2023
1 parent 410d884 commit bae5344
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ At this point in time, it is not yet decided what the next steps will be. Ktlint
* Ignore property with name `serialVersionUID` in `property-naming` ([#2045](https://github.com/pinterest/ktlint/issues/2045))
* Prevent incorrect reporting of violations in case a nullable function type reference exceeds the maximum line length `parameter-list-wrapping` ([#1324](https://github.com/pinterest/ktlint/issues/1324))
* Prevent false negative on `else` branch when body contains only chained calls or binary expression ([#2057](https://github.com/pinterest/ktlint/issues/2057))
* Fix indent when property value is wrapped to next line ([#2095](https://github.com/pinterest/ktlint/issues/2095))

### Changed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public class PropertyWrappingRule :
)
LOGGER.trace { "$line: " + ((if (!autoCorrect) "would have " else "") + "inserted newline before ${node.text}") }
if (autoCorrect) {
node.upsertWhitespaceBeforeMe(node.indent())
node.upsertWhitespaceBeforeMe(indentConfig.childIndentOf(node))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ internal class PropertyWrappingRuleTest {
""".trimIndent()
propertyWrappingRuleAssertThat(code)
.setMaxLineLength()
.addAdditionalRuleProvider { IndentationRule() }
.hasLintViolation(2, 34, "Missing newline after \":\"")
.isFormattedAs(formattedCode)
}
Expand All @@ -46,7 +45,6 @@ internal class PropertyWrappingRuleTest {
""".trimIndent()
propertyWrappingRuleAssertThat(code)
.setMaxLineLength()
.addAdditionalRuleProvider { IndentationRule() }
.hasLintViolation(2, 30, "Missing newline before \"TypeWithALongName\"")
.isFormattedAs(formattedCode)
}
Expand All @@ -69,7 +67,6 @@ internal class PropertyWrappingRuleTest {
""".trimIndent()
propertyWrappingRuleAssertThat(code)
.setMaxLineLength()
.addAdditionalRuleProvider { IndentationRule() }
.hasLintViolations(
LintViolation(2, 50, "Missing newline after \"=\""),
LintViolation(3, 49, "Missing newline before \"TypeWithALongName(123)\""),
Expand All @@ -93,7 +90,6 @@ internal class PropertyWrappingRuleTest {
""".trimIndent()
propertyWrappingRuleAssertThat(code)
.setMaxLineLength()
.addAdditionalRuleProvider { IndentationRule() }
.hasLintViolation(2, 50, "Missing newline before \"TypeWithALongName(123)\"")
.isFormattedAs(formattedCode)
}
Expand Down

0 comments on commit bae5344

Please # to comment.