Skip to content

Commit

Permalink
Router: observe source=keep even when binpacking
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Jan 20, 2022
1 parent 2fc85ab commit 3bba344
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1478,8 +1478,11 @@ class Router(formatOps: FormatOps) {
s.map { x => if (x.isNL) x else x.switch(trigger, true) }
}
} else NoPolicy
val noSpace =
style.newlines.source.eq(Newlines.keep) && newlines != 0
Seq(
Split(Space, 0).withSingleLine(endOfSingleLineBlock(optFT)),
Split(noSpace, 0)(Space)
.withSingleLine(endOfSingleLineBlock(optFT)),
Split(Newline, 1).withPolicy(nlPolicy & indentOncePolicy)
)
}
Expand Down
4 changes: 3 additions & 1 deletion scalafmt-tests/src/test/resources/binPack/LiteralList.stat
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ object a {
>>>
object a {
val foo = app.search(
bar.baz, qux.foo, bar.qux, baz, bar
bar.baz,
qux.foo, bar.qux,
baz, bar
)
}
42 changes: 22 additions & 20 deletions scalafmt-tests/src/test/resources/newlines/source_keep.stat
Original file line number Diff line number Diff line change
Expand Up @@ -4765,8 +4765,8 @@ object a {
}
>>>
object a {
def foo(bb: BB, cc: CC, dd: DD = DDD.ddd): Bar[
Baz] = {
def foo(bb: BB, cc: CC,
dd: DD = DDD.ddd): Bar[Baz] = {
// c
qux
}
Expand Down Expand Up @@ -4877,20 +4877,21 @@ object a {
>>>
object a {
when(
service.list(ApiAudienceFilter(tenants = Contains(Seq(ATenant))), Page(0, Page.maxPageLimit),
Order.default)
service.list(ApiAudienceFilter(tenants = Contains(Seq(ATenant))),
Page(0, Page.maxPageLimit), Order.default)
).thenReturn(PageResult(Seq(audience, audience.copy(id = 2)), PageInfo(50, 0, 10)))

when(
service.list(ApiAudienceFilter(tenants), Contains(Seq(ATenant)), Page(0, Page.maxPageLimit),
Order.default)
service.list(ApiAudienceFilter(tenants), Contains(Seq(ATenant)),
Page(0, Page.maxPageLimit), Order.default)
).thenReturn(PageResult(Seq(audience, audience.copy(id = 2)), PageInfo(50, 0, 10)))

when(service.list(ApiAudienceFilter(tenants), Contains(Seq(ATenant))), Page(0, Page.maxPageLimit),
Order.default).thenReturn(PageResult(Seq(audience, audience.copy(id = 2)), PageInfo(50, 0, 10)))
when(service.list(ApiAudienceFilter(tenants), Contains(Seq(ATenant))),
Page(0, Page.maxPageLimit), Order.default).thenReturn(
PageResult(Seq(audience, audience.copy(id = 2)), PageInfo(50, 0, 10)))

when(service.list(ApiAudienceFilter(tenants), Contains(Seq(ATenant))), Page(0, Page.maxPageLimit),
Order.default,
when(service.list(ApiAudienceFilter(tenants), Contains(Seq(ATenant))),
Page(0, Page.maxPageLimit), Order.default,
PageResult(Seq(audience, audience.copy(id = 2)), PageInfo(50, 0, 10))).thenReturn(None)
}
<<< unsafeCallSite = always, nested with one arg
Expand Down Expand Up @@ -4944,19 +4945,20 @@ object a {
}
>>>
object a {
when(service.list(ApiAudienceFilter(tenants = Contains(Seq(ATenant))), Page(0, Page.maxPageLimit),
Order.default)).thenReturn(PageResult(Seq(audience, audience.copy(id = 2)),
PageInfo(50, 0, 10)))
when(service.list(ApiAudienceFilter(tenants = Contains(Seq(ATenant))),
Page(0, Page.maxPageLimit), Order.default)).thenReturn(PageResult(Seq(audience,
audience.copy(id = 2)), PageInfo(50, 0, 10)))

when(service.list(ApiAudienceFilter(tenants), Contains(Seq(ATenant)), Page(0, Page.maxPageLimit),
Order.default)).thenReturn(PageResult(Seq(audience, audience.copy(id = 2)),
PageInfo(50, 0, 10)))
when(service.list(ApiAudienceFilter(tenants), Contains(Seq(ATenant)),
Page(0, Page.maxPageLimit), Order.default)).thenReturn(PageResult(Seq(audience,
audience.copy(id = 2)), PageInfo(50, 0, 10)))

when(service.list(ApiAudienceFilter(tenants), Contains(Seq(ATenant))), Page(0, Page.maxPageLimit),
Order.default).thenReturn(PageResult(Seq(audience, audience.copy(id = 2)), PageInfo(50, 0, 10)))
when(service.list(ApiAudienceFilter(tenants), Contains(Seq(ATenant))),
Page(0, Page.maxPageLimit), Order.default).thenReturn(PageResult(Seq(audience,
audience.copy(id = 2)), PageInfo(50, 0, 10)))

when(service.list(ApiAudienceFilter(tenants), Contains(Seq(ATenant))), Page(0, Page.maxPageLimit),
Order.default,
when(service.list(ApiAudienceFilter(tenants), Contains(Seq(ATenant))),
Page(0, Page.maxPageLimit), Order.default,
PageResult(Seq(audience, audience.copy(id = 2)), PageInfo(50, 0, 10))).thenReturn(None)
}
<<< #2821 default
Expand Down

0 comments on commit 3bba344

Please sign in to comment.