From 08ee8973dc24ee2a3b58967afef1f3d96338db81 Mon Sep 17 00:00:00 2001 From: Albert Meltzer <7529386+kitbellew@users.noreply.github.com> Date: Thu, 26 Dec 2024 16:53:24 -0800 Subject: [PATCH] FormatOps: simplify logic to skip infix indent --- .../main/scala/org/scalafmt/internal/FormatOps.scala | 12 ++---------- 1 file changed, 2 insertions(+), 10 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 a581bb7ba..cf0f09b38 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 @@ -570,23 +570,15 @@ class FormatOps( case _ => false } val cfg = style.indent.infix - val allowNoIndent = cfg.exemptScope match { + def allowNoIndent = cfg.exemptScope match { case IndentOperator.Exempt.all => true case IndentOperator.Exempt.oldTopLevel => isOldTopLevel(getChild) case IndentOperator.Exempt.aloneEnclosed => isAloneEnclosed(getChild) case IndentOperator.Exempt.aloneArgOrBody => isAloneArgOrBody(getChild) } - def isInfixTopLevelMatch(op: String, noindent: Boolean): Boolean = - noindent == cfg.noindent(op) && noindent == allowNoIndent if (cfg.assignmentOnly) isAfterAssignmentOp(false) else if (beforeLhs) assignBodyExpire.isEmpty - else if ( - !app.singleArg.exists(_.isAny[Term.Block, Term.NewAnonymous]) && - isInfixTopLevelMatch(ft.meta.left.text, false) - ) false - else if (isInfixTopLevelMatch(app.op.value, true)) true - else if (app.is[Pat] && isChildOfCaseClause(app)) true - else false + else app.is[Pat] || allowNoIndent && cfg.noindent(app.op.value) } private val fullIndent: Indent = assignBodyExpire match {