Skip to content

Commit

Permalink
FormatOps: fewer-braces func not just in apply
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Aug 31, 2023
1 parent 89fb867 commit b8c334e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2130,8 +2130,7 @@ class FormatOps(
def owner = t.parent
def splits = Some(t.values match {
case (tf: Term.FunctionTerm) :: Nil
if !style.newlines.alwaysBeforeCurlyLambdaParams &&
t.parent.exists(_.is[Term.Apply]) =>
if !style.newlines.alwaysBeforeCurlyLambdaParams =>
getSplits(ft, t, forceNL = false, indentOpt = indent) match {
case s +: rs if !s.isNL => funcSplit(tf)(s.fileLine) +: rs
case ss => ss
Expand Down
10 changes: 4 additions & 6 deletions scalafmt-tests/src/test/resources/scala3/OptionalBraces.stat
Original file line number Diff line number Diff line change
Expand Up @@ -5167,18 +5167,16 @@ object a:
List(1, 2, 3) map: x =>
x + 1
>>>
test does not parse
object a:
List(1, 2, 3) map: x => x + 1
^
List(1, 2, 3) map:
x => x + 1
<<< #3623 !beforeCurlyLambdaParams
newlines.beforeCurlyLambdaParams = false
===
object a:
List(1, 2, 3) map: x =>
x + 1
>>>
test does not parse
object a:
List(1, 2, 3) map: x => x + 1
^
List(1, 2, 3) map: x =>
x + 1
Original file line number Diff line number Diff line change
Expand Up @@ -4934,18 +4934,16 @@ object a:
List(1, 2, 3) map: x =>
x + 1
>>>
test does not parse
object a:
List(1, 2, 3) map: x => x + 1
^
List(1, 2, 3) map:
x => x + 1
<<< #3623 !beforeCurlyLambdaParams
newlines.beforeCurlyLambdaParams = false
===
object a:
List(1, 2, 3) map: x =>
x + 1
>>>
test does not parse
object a:
List(1, 2, 3) map: x => x + 1
^
List(1, 2, 3) map: x =>
x + 1
Original file line number Diff line number Diff line change
Expand Up @@ -5202,8 +5202,9 @@ object a:
x + 1
>>>
object a:
List(1, 2, 3) map: x =>
x + 1
List(1, 2, 3) map:
x =>
x + 1
<<< #3623 !beforeCurlyLambdaParams
newlines.beforeCurlyLambdaParams = false
===
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5333,18 +5333,16 @@ object a:
List(1, 2, 3) map: x =>
x + 1
>>>
test does not parse
object a:
List(1, 2, 3) map: x => x + 1
^
List(1, 2, 3) map:
x => x + 1
<<< #3623 !beforeCurlyLambdaParams
newlines.beforeCurlyLambdaParams = false
===
object a:
List(1, 2, 3) map: x =>
x + 1
>>>
test does not parse
object a:
List(1, 2, 3) map: x => x + 1
^
List(1, 2, 3) map: x =>
x + 1

0 comments on commit b8c334e

Please sign in to comment.