Skip to content

Commit

Permalink
Fixing bug with extra indentation after lambda arrow
Browse files Browse the repository at this point in the history
  • Loading branch information
shashachu committed Jul 3, 2019
1 parent 0fef759 commit 532f03c
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -707,11 +707,14 @@ class IndentationRule : Rule("indent"), Rule.Modifier.RestrictToRootLast {
}

private fun adjustExpectedIndentAfterArrow(n: ASTNode, ctx: IndentContext) {
val prevBlockLine = ctx.blockOpeningLineStack.peek() ?: -1
if (prevBlockLine != line) {
expectedIndent++
debug { "++after(ARROW) -> $expectedIndent" }
ctx.exitAdjBy(n.treeParent, -1)
// Only adjust indents for arrows inside of when statements. Lambda arrows should not increase indent.
if (n.treeParent?.elementType == WHEN_ENTRY) {
val prevBlockLine = ctx.blockOpeningLineStack.peek() ?: -1
if (prevBlockLine != line) {
expectedIndent++
debug { "++after(ARROW) -> $expectedIndent" }
ctx.exitAdjBy(n.treeParent, -1)
}
}
}

Expand Down

0 comments on commit 532f03c

Please sign in to comment.