Skip to content

Commit

Permalink
Router: use dangle for binPack when not cfgstyle
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Dec 23, 2021
1 parent 96e62eb commit 7d4a248
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,8 @@ class Router(formatOps: FormatOps) {
else None

val mustDangle = onlyConfigStyle ||
style.newlines.sourceIgnored && style.danglingParentheses.defnSite
style.danglingParentheses.defnSite &&
(style.newlines.sourceIgnored || !style.optIn.configStyleArguments)
def noSplitPolicy: Policy =
if (mustDangle || style.newlines.source.eq(Newlines.unfold))
slbPolicy
Expand Down Expand Up @@ -1245,7 +1246,7 @@ class Router(formatOps: FormatOps) {
} else if (
mustDangleForTrailingCommas ||
style.danglingParentheses.tupleOrCallSite(isTuple(leftOwner)) &&
style.newlines.sourceIgnored
(style.newlines.sourceIgnored || !style.optIn.configStyleArguments)
)
newlineBeforeClose & binPackOnelinePolicy
else binPackOnelinePolicy
Expand Down
10 changes: 6 additions & 4 deletions scalafmt-tests/src/test/resources/newlines/source_classic.stat
Original file line number Diff line number Diff line change
Expand Up @@ -2553,7 +2553,8 @@ object a {
object a {
val foo = bar.map(x =>
x.copy(
baz = Option.when(false)(x.qux))
baz = Option.when(false)(x.qux)
)
)
}
<<< binPack with named parameter values, !danglingParentheses
Expand Down Expand Up @@ -2679,9 +2680,10 @@ object a {
}
>>>
object a {
protected def foo[U](bar: String,
baz: Seq[String] = Seq.empty)(
f: HttpResponse => U): U = qux
protected def foo[U](
bar: String,
baz: Seq[String] = Seq.empty
)(f: HttpResponse => U): U = qux
}
<<< #1973 1
maxColumn = 25
Expand Down
15 changes: 10 additions & 5 deletions scalafmt-tests/src/test/resources/newlines/source_keep.stat
Original file line number Diff line number Diff line change
Expand Up @@ -2641,7 +2641,8 @@ object a {
bar.baz(Seq(
Qux(
"", 1, "par1", "2018-01-01", "2018-12-31", "2018-01-01", "2018-02-01", None, None, 1000,
Some(0), Some(1), foo = Some("bar"))
Some(0), Some(1), foo = Some("bar")
)
))
)
}
Expand All @@ -2666,7 +2667,8 @@ object a {
>>>
object a {
private val audience3 = apiAudience(
3, "b_name", Sams, Inid, "2", "created-by-user2", "updated-by-user2").copy(
3, "b_name", Sams, Inid, "2", "created-by-user2", "updated-by-user2"
).copy(
updatedAt = nowDate.minusDays(15),
audienceSizeOnsite = Some(3333),
audienceSizeOffsite = Some(1)
Expand All @@ -2683,9 +2685,12 @@ object a {
}
>>>
object a {
protected def foo[U](bar: String,
baz: Seq[String] = Seq.empty)(
f: HttpResponse => U): U = qux
protected def foo[U](
bar: String,
baz: Seq[String] = Seq.empty
)(
f: HttpResponse => U
): U = qux
}
<<< #1973 1
maxColumn = 25
Expand Down

0 comments on commit 7d4a248

Please sign in to comment.