diff --git a/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/FormatOps.scala b/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/FormatOps.scala index 3d9d41a01..d6cc791af 100644 --- a/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/FormatOps.scala +++ b/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/FormatOps.scala @@ -960,6 +960,8 @@ class FormatOps( ) } else if (!isFirstCtor) Seq(Split(Space, 0), Split(Newline, 1)) + else if (style.binPack.parentConstructors eq BinPack.ParentCtors.ForceBreak) + Seq(Split(nlMod, 0, policy = nlPolicy(false)).withIndent(indent)) else { val parentCtors = style.binPack.parentConstructors val nlOnelineTag = parentCtors match { diff --git a/scalafmt-tests/shared/src/test/resources/binPack/ParentConstructors.stat b/scalafmt-tests/shared/src/test/resources/binPack/ParentConstructors.stat index 4757c688f..d15cae703 100644 --- a/scalafmt-tests/shared/src/test/resources/binPack/ParentConstructors.stat +++ b/scalafmt-tests/shared/src/test/resources/binPack/ParentConstructors.stat @@ -302,7 +302,9 @@ binPack.parentConstructors = ForceBreak === class SomeClass(a: Int, b: Double, c: String) extends SomeBaseClass with SomeTrait >>> -class SomeClass(a: Int, b: Double, c: String) extends SomeBaseClass with SomeTrait +class SomeClass(a: Int, b: Double, c: String) + extends SomeBaseClass + with SomeTrait <<< #4542 ForceBreak narrow multi-line maxColumn = 40 binPack.parentConstructors = ForceBreak @@ -336,4 +338,6 @@ class SomeClass(a: Int, b: Double, c: String) extends SomeBaseClass with SomeTrait >>> -class SomeClass(a: Int, b: Double, c: String) extends SomeBaseClass with SomeTrait +class SomeClass(a: Int, b: Double, c: String) + extends SomeBaseClass + with SomeTrait diff --git a/scalafmt-tests/shared/src/test/scala/org/scalafmt/FormatTests.scala b/scalafmt-tests/shared/src/test/scala/org/scalafmt/FormatTests.scala index 02dd9a06b..325b2f890 100644 --- a/scalafmt-tests/shared/src/test/scala/org/scalafmt/FormatTests.scala +++ b/scalafmt-tests/shared/src/test/scala/org/scalafmt/FormatTests.scala @@ -137,7 +137,7 @@ class FormatTests extends FunSuite with CanRunTests with FormatAssertions { val explored = Debug.explored.get() logger.debug(s"Total explored: $explored") if (!onlyUnit && !onlyManual) - assertEquals(explored, 1117354, "total explored") + assertEquals(explored, 1117350, "total explored") val results = debugResults.result() // TODO(olafur) don't block printing out test results. // I don't want to deal with scalaz's Tasks :'(