Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix indent when property value is wrapped #2097

Merged
merged 1 commit into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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