Skip to content

Commit

Permalink
Router: allow empty parameter list to align
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Aug 26, 2022
1 parent f8e2b84 commit 94b4571
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ class Router(formatOps: FormatOps) {
)
}
val argsOpt = if (isAlignFirstParen) getArgsOpt else None
argsOpt.map(x => tokens.tokenAfter(x).right).fold(splits) { x =>
argsOpt.flatMap(tokens.tokenAfterOpt).map(_.right).fold(splits) { x =>
val noSplitIndents = Seq(
Indent(StateColumn, x, ExpiresOn.Before),
Indent(-indentLen, x, ExpiresOn.Before)
Expand All @@ -781,7 +781,7 @@ class Router(formatOps: FormatOps) {
}
getSplitsBeforeOpenParen(x, indent, _.beforeOpenParenDefnSite) {
rightOwner match {
case SplitDefnIntoParts(_, _, _, args) => Some(args.last)
case SplitDefnIntoParts(_, _, _, args) => args.lastOption
case _ => None
}
}
Expand Down
6 changes: 5 additions & 1 deletion scalafmt-tests/src/test/resources/default/Class.stat
Original file line number Diff line number Diff line change
Expand Up @@ -562,4 +562,8 @@ object Record {
final case class NotOk[A]() extends Record[A]
}
>>>
org.scalafmt.util.FormatException: java.util.NoSuchElementException: last of empty list
object Record {
final case class IsOk[A](a: A) extends InvariantADT[A]
final case class AlsoOk[A](msg: String) extends InvariantADT[A]
final case class NotOk[A]() extends Record[A]
}

0 comments on commit 94b4571

Please sign in to comment.