From ce4f2f9cb7ffa4a08af71b09de21673f48af2ba7 Mon Sep 17 00:00:00 2001 From: Albert Meltzer <7529386+kitbellew@users.noreply.github.com> Date: Sat, 18 May 2024 14:45:00 -0700 Subject: [PATCH] FormatOps: return for fewer braces infix lhs early --- .../src/main/scala/org/scalafmt/internal/FormatOps.scala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 cb71cd15a6..d088ee4085 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 @@ -423,6 +423,8 @@ class FormatOps( Seq(Split(NoSplit, 0)) case t => val isBeforeOp = ft.meta.leftOwner ne app.op + // RETURNING!!! + if (isBeforeOp && isFewerBracesLhs(app.lhs)) return Seq(Split(Newline, 0)) def useSpace = style.spaces.beforeInfixArgInParens(app.op.value) || (app.arg match { case _: Lit.Unit => false @@ -430,8 +432,7 @@ class FormatOps( case x => !isEnclosedInParens(x) }) val afterInfix = style.breakAfterInfix(t) - if (isBeforeOp && isFewerBracesLhs(app.lhs)) Seq(Split(Newline, 0)) - else if (afterInfix ne Newlines.AfterInfix.keep) + if (afterInfix ne Newlines.AfterInfix.keep) if (isBeforeOp) Seq(Split(Space, 0)) else { val spaceMod = Space(useSpace)