Skip to content

Commit cd8f456

Browse files
committed
FormatOps: fix an overly aggressive optimal token
1 parent 1ccaa47 commit cd8f456

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

scalafmt-core/shared/src/main/scala/org/scalafmt/internal/FormatOps.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ class FormatOps(
153153
case t if t.end >= end => Some(start.left)
154154
case _ if start.hasBlankLine => Some(start.left)
155155
case _: T.RightParen
156-
if start.left.is[T.RightParen] || start.left.is[T.LeftParen] =>
156+
if start.left.is[T.LeftParen] || start.left.is[T.RightParen] &&
157+
!start.meta.rightOwner.is[Member.SyntaxValuesClause] =>
157158
None
158159
case _: T.RightBracket if start.left.is[T.RightBracket] => None
159160
case _: T.Comma | _: T.LeftParen | _: T.Semicolon | _: T.RightArrow |

scalafmt-tests/src/test/resources/newlines/source_fold.stat

+4-5
Original file line numberDiff line numberDiff line change
@@ -7034,8 +7034,7 @@ class a {
70347034
)(in: Input[E]): Iteratee[E, Iteratee[E, A]] = in match {
70357035
case Input.El(e) => Iteratee.flatten(
70367036
Future(p(e))(pec).map(b =>
7037-
if (b) Done(inner, in)
7038-
else stepNoBreak(inner)(in)
7037+
if (b) Done(inner, in) else stepNoBreak(inner)(in)
70397038
)(dec)
70407039
)
70417040
case _ => stepNoBreak(inner)(in)
@@ -7051,9 +7050,9 @@ class a {
70517050
}
70527051
>>>
70537052
class a {
7054-
atPos(body.pos)(casegen.one(substitution(
7055-
body
7056-
))) // since SubstOnly treemakers are dropped, need to do it here
7053+
atPos(body.pos)(casegen.one(
7054+
substitution(body)
7055+
)) // since SubstOnly treemakers are dropped, need to do it here
70577056
}
70587057
<<< SM 7.4.0: 52
70597058
maxColumn = 76

0 commit comments

Comments
 (0)