Skip to content

Commit

Permalink
IndentationRule: fix wrong indentation in named arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
t-kameyama committed Nov 17, 2020
1 parent b4f0844 commit d056750
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ class IndentationRule : Rule("indent"), Rule.Modifier.RestrictToRootLast {
// class C :
// SUPER_TYPE_LIST
adjustExpectedIndentInFrontOfSuperTypeList(n, ctx)
prevLeaf?.elementType == EQ ->
prevLeaf?.elementType == EQ && p.elementType != VALUE_ARGUMENT ->
// v =
// value
adjustExpectedIndentAfterEq(n, ctx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,4 +625,41 @@ internal class IndentationRuleTest {
)
).isEmpty()
}

@Test
fun `lint named argument`() {
assertThat(
IndentationRule().lint(
"""
data class D(val a: Int, val b: Int, val c: Int)
fun test() {
val d = D(
a = 1,
b =
2,
c = 3
)
}
""".trimIndent()
)
).isEmpty()
}

@Test
fun `lint default parameter`() {
assertThat(
IndentationRule().lint(
"""
data class D(
val a: Int = 1,
val b: Int =
2,
val c: Int = 3
)
""".trimIndent()
)
).isEmpty()
}
}

0 comments on commit d056750

Please sign in to comment.