Skip to content

Commit

Permalink
Newlines: add forceBeforeAssign
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Aug 11, 2022
1 parent b9dae51 commit ebd6073
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -1746,6 +1746,19 @@ class A {
}
```

### `newlines.forceBeforeAssign`

> Since v3.5.9
```scala mdoc:defaults
newlines.forceBeforeAssign
```

This parameter takes precedence over
[`newlines.forceBeforeMultilineAssign`](#newlinesforcebeforemultilineassign)
and uses the same values. The difference is, the rule forces a newline before a
matching assignment expression whether or not it can be formatted on a single line.

### `newlines.beforeTypeBounds`

> Since v3.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ case class Newlines(
@annotation.ExtraName("usingParamListModifierPrefer")
implicitParamListModifierPrefer: Option[BeforeAfter] = None,
alwaysBeforeElseAfterCurlyIf: Boolean = false,
forceBeforeAssign: ForceBeforeMultilineAssign =
ForceBeforeMultilineAssign.never,
private val forceBeforeMultilineAssign: Option[ForceBeforeMultilineAssign] =
None,
@annotation.DeprecatedName(
Expand Down
7 changes: 7 additions & 0 deletions scalafmt-tests/src/test/resources/newlines/source_unfold.stat
Original file line number Diff line number Diff line change
Expand Up @@ -6121,3 +6121,10 @@ class Foo() {
a + b
}.foo
}
<<< #3271
newlines.forceBeforeAssign = def
===
def sum(a: Int, b: Int): Int =
a + b
>>>
def sum(a: Int, b: Int): Int = a + b

0 comments on commit ebd6073

Please sign in to comment.