Skip to content

Commit

Permalink
Fix indentation with lambda argument, Fix #622 (#627)
Browse files Browse the repository at this point in the history
* Fix indentation with lambda

* Add test for format
  • Loading branch information
yukukotani authored and Tapchicoma committed Nov 5, 2019
1 parent 2e7d67c commit b41aa22
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ class IndentationRule : Rule("indent"), Rule.Modifier.RestrictToRootLast {
}

private fun adjustExpectedIndentInsideQualifiedExpression(n: ASTNode, ctx: IndentContext) {
val p = n.treeParent
val p = n.parent({ it.treeParent.elementType != DOT_QUALIFIED_EXPRESSION }) ?: return
val nextSibling = n.treeNext
if (!ctx.ignored.contains(p) && nextSibling != null) {
expectedIndent++
Expand All @@ -631,7 +631,8 @@ class IndentationRule : Rule("indent"), Rule.Modifier.RestrictToRootLast {
} else {
nextSibling
}
ctx.exitAdjBy(e, -1)
ctx.ignored.add(p)
ctx.exitAdjBy(p, -1)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ public class ThisIsASampleClass :
}
}

fun foo3() {
Integer
.parseInt("32").let {
println("parsed $it")
}
}

private val f =
{ a: Int -> a * 2 }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ return 2
}
}

fun foo3() {
Integer
.parseInt("32").let {
println("parsed $it")
}
}

private val f =
{ a: Int -> a * 2 }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,11 @@ fun f4() = "${
true
}"

fun f5() {
Integer
.parseInt("32").let {
println("parsed $it")
}
}

// expect

0 comments on commit b41aa22

Please sign in to comment.