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: fix bp.callsite=oneline penalty bug #4004

Merged
merged 2 commits into from
May 17, 2024
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 @@ -1231,7 +1231,8 @@ class Router(formatOps: FormatOps) {
penalizeNewlinesPolicy
else {
val slbEnd = nextCommaOneline.getOrElse(close)
SingleLineBlock(slbEnd, noSyntaxNL = true)
SingleLineBlock(slbEnd, noSyntaxNL = true) |
penalizeNewlinesPolicy
}
}
val indentPolicy =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5130,8 +5130,9 @@ object a {
}
>>>
object a {
def foo(dd: DD[AA[BB],
CC] = DDD.ddd): Bar[Baz] = {
def foo(
dd: DD[AA[BB], CC] = DDD.ddd
): Bar[Baz] = {
// c
qux
}
Expand Down Expand Up @@ -5173,8 +5174,8 @@ object a {
}
>>>
object a {
def foo(dd: DD[AA[BB],
CC] = DDDD.dddd) = {
def foo(dd: DD[AA[BB], CC] =
DDDD.dddd) = {
// c
qux
}
Expand Down
14 changes: 7 additions & 7 deletions scalafmt-tests/src/test/resources/newlines/source_fold.stat
Original file line number Diff line number Diff line change
Expand Up @@ -2644,13 +2644,13 @@ object a {
>>>
object a {
test("foo") {
a.b(c, d) shouldBe
E(Seq(F(1, "v1"), F(2, "v2")),
G(Some(Seq(h, i)),
Some(Seq(j, k)), a.b, c.d,
e.f.g, h.i.j
)
).foo
a.b(c, d) shouldBe E(
Seq(F(1, "v1"), F(2, "v2")),
G(Some(Seq(h, i)),
Some(Seq(j, k)), a.b, c.d,
e.f.g, h.i.j
)
).foo
}
}
<<< binpack call, oneline, with syntaxNL, single arg
Expand Down
21 changes: 17 additions & 4 deletions scalafmt-tests/src/test/resources/scalajs/Apply.stat
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ object a {
val a = foo bar (
baz = qux)
}
<<< binpack with infix rhs in parens, 2 args
<<< binpack with infix rhs in parens, 2 args, bp=oneline
maxColumn = 25
binPack.unsafeCallSite = oneline
indentOperator.topLevelOnly = false
Expand All @@ -935,9 +935,22 @@ object a {
}
>>>
object a {
val a =
foo bar (baz = qux,
bar = qux)
val a = foo bar (
baz = qux, bar = qux)
}
<<< binpack with infix rhs in parens, 2 args, bp=always
maxColumn = 25
binPack.unsafeCallSite = always
indentOperator.topLevelOnly = false
indent.callSite = 2
===
object a {
val a = foo bar (baz = qux, bar = qux)
}
>>>
object a {
val a = foo bar (
baz = qux, bar = qux)
}
<<< binpack with infix match rhs in parens
maxColumn = 25
Expand Down
23 changes: 23 additions & 0 deletions scalafmt-tests/src/test/resources/scalajs/DefDef.stat
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,29 @@ object a {
R] =
(x1, x12) => f(x1, x12)
}
<<< one of the commas right on maxColumn boundary, oneline
preset = default
maxColumn = 80
newlines.source = keep
binPack.preset = oneline
danglingParentheses.preset = false
newlines.configStyleDefnSite.prefer = true
newlines.avoidForSimpleOverflow = [tooLong, punct, slc]
===
object a {
implicit def fromFunction17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, R](f: scala.Function17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, R]): js.Function17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, R] = (x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6, x7: T7, x8: T8, x9: T9, x10: T10, x11: T11, x12: T12, x13: T13, x14: T14, x15: T15, x16: T16, x17: T17) => f(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17)
}
>>>
object a {
implicit def fromFunction17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
T13, T14, T15, T16, T17, R](
f: scala.Function17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
T13, T14, T15, T16, T17, R]): js.Function17[T1, T2, T3, T4, T5, T6, T7,
T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, R] = (x1: T1, x2: T2,
x3: T3, x4: T4, x5: T5, x6: T6, x7: T7, x8: T8, x9: T9, x10: T10,
x11: T11, x12: T12, x13: T13, x14: T14, x15: T15, x16: T16, x17: T17) =>
f(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17)
}
<<< break at maxColumn, with overflow enabled 1
preset = default
maxColumn = 80
Expand Down
Loading