Skip to content

Commit

Permalink
Define Newlines.BeforeCurlyLambdaParams.multiline
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Sep 11, 2020
1 parent 57790d9 commit f135eb8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,13 @@ object Newlines {
object BeforeCurlyLambdaParams {
case object always extends BeforeCurlyLambdaParams
case object never extends BeforeCurlyLambdaParams
case object multiline extends BeforeCurlyLambdaParams
case object multilineWithCaseOnly extends BeforeCurlyLambdaParams
implicit val codec: ConfCodec[BeforeCurlyLambdaParams] =
ReaderUtil.oneOfCustom[BeforeCurlyLambdaParams](
never,
always,
multiline,
multilineWithCaseOnly
) {
case Conf.Bool(true) => Configured.Ok(always)
Expand Down
29 changes: 29 additions & 0 deletions scalafmt-tests/src/test/resources/unit/Lambda.stat
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,32 @@ object a {
s"$c -> $i"
}
}
<<< ONLY #2099 beforeCurlyLambdaParams = multiline
newlines.beforeCurlyLambdaParams = multiline
===
object a {
x.map { x => s"${x._1} -> ${x._2}" }
x.map { case (c, i) => s"$c -> $i" }
x.zipWithIndex.map { x => s"${x._1} -> ${x._2}" }
x.zipWithIndex.map { case (c, i) => s"$c -> $i" }
x.zipWithIndex.map { case (c, i) => s"$c -> $i (long comment)" }
x.zipWithIndex.map { case (c, i) if c != i => s"$c -> $i" }
}
>>>
object a {
x.map { x => s"${x._1} -> ${x._2}" }
x.map { case (c, i) => s"$c -> $i" }
x.zipWithIndex.map { x =>
s"${x._1} -> ${x._2}"
}
x.zipWithIndex.map { case (c, i) =>
s"$c -> $i"
}
x.zipWithIndex.map { case (c, i) =>
s"$c -> $i (long comment)"
}
x.zipWithIndex.map {
case (c, i) if c != i =>
s"$c -> $i"
}
}

0 comments on commit f135eb8

Please sign in to comment.