diff --git a/docs/configuration.md b/docs/configuration.md index bfcdf77f94..7fa5c29917 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -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 diff --git a/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/Router.scala b/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/Router.scala index c9c82a227b..4b738635f9 100644 --- a/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/Router.scala +++ b/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/Router.scala @@ -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 || diff --git a/scalafmt-tests/src/test/resources/newlines/source_keep.stat b/scalafmt-tests/src/test/resources/newlines/source_keep.stat index 376319fc50..73ccfa3d62 100644 --- a/scalafmt-tests/src/test/resources/newlines/source_keep.stat +++ b/scalafmt-tests/src/test/resources/newlines/source_keep.stat @@ -7483,8 +7483,7 @@ object Main { object Main { val bar1 = foo1( 10000, - 10001, - 10002 + 0 + 10001, 10002 + 0 ) val bar2 = foo2( 0, @@ -7619,8 +7618,7 @@ object Main { object Main { val bar1 = foo1( 10000, - 10001, - 10002 + 0 + 10001, 10002 + 0 ) val bar2 = foo2( 0,