Skip to content

Commit

Permalink
BinPack.ParentCtors: add new ForceBreak option
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Nov 15, 2024
1 parent 9fce910 commit fa7850e
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 1 deletion.
15 changes: 15 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -5138,6 +5138,21 @@ object A {
}
```

#### `binPack.parentConstructors=ForceBreak`

This option will enforce a break before each parent. As usual, the break is only
actually introduced if indented position on the next line is less than the current.

```scala mdoc:scalafmt
binPack.parentConstructors = ForceBreak
maxColumn = 45
---
object A {
class Foo(a: Int) extends Bar with Baz
class Foo(a: Int, b: Int, c: String, d: Double) extends Bar with Baz
}
```

### `binPack.xxxSite`

Controls binpacking around method/type definition sites (`binPack.defnSite`) or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ object BinPack {
case object keep extends ParentCtors
case object Always extends ParentCtors
case object Never extends ParentCtors
case object ForceBreak extends ParentCtors
case object Oneline extends ParentCtors
case object OnelineIfPrimaryOneline extends ParentCtors

Expand All @@ -112,6 +113,7 @@ object BinPack {
keep,
Always,
Never,
ForceBreak,
Oneline,
OnelineIfPrimaryOneline,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,65 @@ object foo extends bar(baz) with foo with baz
object foo
extends bar(baz)
with foo with baz
<<< #4542 ForceBreak narrow single-line
maxColumn = 40
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
<<< #4542 ForceBreak medium single-line
maxColumn = 50
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
<<< #4542 ForceBreak wide single-line
maxColumn = 100
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
<<< #4542 ForceBreak narrow multi-line
maxColumn = 40
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
<<< #4542 ForceBreak medium multi-line
maxColumn = 50
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
<<< #4542 ForceBreak wide multi-line
maxColumn = 100
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
Original file line number Diff line number Diff line change
Expand Up @@ -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, 1117062, "total explored")
assertEquals(explored, 1117354, "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 :'(
Expand Down

0 comments on commit fa7850e

Please sign in to comment.