Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Router: use dangle for binPack when not cfgstyle #2979

Merged
merged 1 commit into from
Dec 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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