Skip to content

Commit

Permalink
Router: fix configStyle/binPack.callSite/src=keep
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Apr 8, 2024
1 parent d4a3a2e commit 9799526
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -4878,7 +4878,7 @@ and similarly has cross-parameter interactions:
- interaction with `config-style` parameters:
- when [config-style is forced](#forcing-config-style), it takes precedence
over binpacking
- for `newlines.source=classic/keep`, formatting is mandated by the
- for `newlines.source=classic`, formatting is mandated by the
[scala.js](https://github.com/scala-js/scala-js/pull/4522#issuecomment-879168123)
coding style, determined by the position of the closing parenthesis; "tucked"
parenthesis enables binpacking, while "dangling" one forces config-style
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,11 @@ class Router(formatOps: FormatOps) {
if (needOnelinePolicy) nextCommaOnelinePolicy else Some(NoPolicy)
def bothPolicies = newlineBeforeClose & binPackOnelinePolicyOpt
if (onlyConfigStyle != ConfigStyle.None)
if (styleMap.forcedBinPack(leftOwner)) bothPolicies
if (
(style.newlines.source == Newlines.keep &&
onlyConfigStyle == ConfigStyle.Source) ||
styleMap.forcedBinPack(leftOwner)
) bothPolicies
else splitOneArgOneLine(close, leftOwner) | newlineBeforeClose
else if (
mustDangleForTrailingCommas ||
Expand Down
6 changes: 2 additions & 4 deletions scalafmt-tests/src/test/resources/newlines/source_keep.stat
Original file line number Diff line number Diff line change
Expand Up @@ -7483,8 +7483,7 @@ object Main {
object Main {
val bar1 = foo1(
10000,
10001,
10002 + 0
10001, 10002 + 0
)
val bar2 = foo2(
0,
Expand Down Expand Up @@ -7619,8 +7618,7 @@ object Main {
object Main {
val bar1 = foo1(
10000,
10001,
10002 + 0
10001, 10002 + 0
)
val bar2 = foo2(
0,
Expand Down

0 comments on commit 9799526

Please sign in to comment.