Skip to content

Commit

Permalink
Fix multi-line indentation in more than call and match expressions.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisNeveu committed Jan 27, 2016
1 parent b0b09a6 commit ad610c4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,10 @@ trait ExprFormatter { self: HasFormattingPreferences with AnnotationFormatter wi
case (_, _: ArgumentExprs) if formattingPreferences(PreserveSpaceBeforeArguments) CompactPreservingGap // TODO: Probably not needed now with CallExpr
case (_, elem) if element.firstTokenOption exists { firstToken newlineBefore(firstToken) && !(Set(COMMA, COLON) contains firstToken.tokenType) }
val isNestedArgument = elem match {
case Argument(Expr(CallExpr(_, _, _, moreArgs, _) :: tail)) if moreArgs.isEmpty false
case Argument(Expr(CallExpr(None, _, _, moreArgs, _) :: tail)) if moreArgs.isEmpty false
case Argument(Expr(EqualsExpr(_, _, Expr(headExpr :: innerTail)) :: tail)) headExpr match {
case CallExpr(children, _, _, moreArgs, _) moreArgs.nonEmpty || headExpr.tokens.exists(tk => hiddenPredecessors(tk).containsNewline)
case MatchExpr(_, _, _) true
case _ false
case _ headExpr.tokens.exists(tk => hiddenPredecessors(tk).containsNewline)
}
case _ true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,21 @@ class IndentWithTabsTest extends AbstractFormatterTest {
|\t"foo",
|\t"bar",
|\tfalse)""".replace("\\t", "\t")

"""sequence(
|authors.grouped(100).map(batch =>
|Object.get[List[SomeType]](
|Foo / "bar" / "baz" / "qux"
|)
|).toList
|).map(_.flatten)""" ==>
"""sequence(
|\tauthors.grouped(100).map(batch =>
|\t\tObject.get[List[SomeType]](
|\t\t\tFoo / "bar" / "baz" / "qux"
|\t\t)
|\t).toList
|).map(_.flatten)""".replace("\\t", "\t")
}

{
Expand Down

0 comments on commit ad610c4

Please sign in to comment.