diff --git a/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/Router.scala b/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/Router.scala index efa4e5e7ef..1eeb9f1b02 100644 --- a/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/Router.scala +++ b/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/Router.scala @@ -1175,6 +1175,7 @@ class Router(formatOps: FormatOps) { val indent = Indent(Num(indentLen), close, Before) val noSplitIndents = if (style.binPack.indentCallSiteOnce) Seq.empty + else if (isSingleArg && oneline && !needOnelinePolicy) Seq.empty else if ( if (isTuple(leftOwner)) style.align.getOpenParenTupleSite else style.align.getOpenDelimSite(false, false) @@ -1217,7 +1218,7 @@ class Router(formatOps: FormatOps) { baseNoSplit .withOptimalTokenOpt(opt) .withPolicy(penalizeNewlinesPolicy) - .andPolicy(unindentPolicy, !isSingleArg) + .andPolicy(unindentPolicy, !isSingleArg || noSplitIndents.isEmpty) .andPolicyOpt(nextCommaOnelinePolicy) } diff --git a/scalafmt-tests/src/test/resources/default/Apply.stat b/scalafmt-tests/src/test/resources/default/Apply.stat index 0d3a905b6e..6ea4cd0ae1 100644 --- a/scalafmt-tests/src/test/resources/default/Apply.stat +++ b/scalafmt-tests/src/test/resources/default/Apply.stat @@ -1773,8 +1773,8 @@ object a { symForName .getAnnotation(JSNameAnnotation).fold { sym.addAnnotation(JSNameAnnotation, - Literal(Constant(jsInterop.defaultJSNameOf( - symForName)))) + Literal(Constant( + jsInterop.defaultJSNameOf(symForName)))) } { annot => sym.addAnnotation(annot) } diff --git a/scalafmt-tests/src/test/resources/newlines/source_classic.stat b/scalafmt-tests/src/test/resources/newlines/source_classic.stat index 2568a51424..6ce3a1c4db 100644 --- a/scalafmt-tests/src/test/resources/newlines/source_classic.stat +++ b/scalafmt-tests/src/test/resources/newlines/source_classic.stat @@ -4501,12 +4501,12 @@ object a { >>> object a { binder.bind("f", params) shouldBe Some(Left( - s"Cannot parse parameter f as DummyEnum, $wrongValue is not a member of Enum (dummy-value)" - )) + s"Cannot parse parameter f as DummyEnum, $wrongValue is not a member of Enum (dummy-value)" + )) when(audienceService.publish(any[Tenant], any[Int])).thenReturn( Success[NonEmptyList[String], ApiAudience](apiAudience - .copy(status = AudienceStatus.Pending.name)) + .copy(status = AudienceStatus.Pending.name)) ) } <<< unsafeCallSite = Oneline, nested with one arg, several options diff --git a/scalafmt-tests/src/test/resources/newlines/source_fold.stat b/scalafmt-tests/src/test/resources/newlines/source_fold.stat index a49e733ffc..bccf3c61d7 100644 --- a/scalafmt-tests/src/test/resources/newlines/source_fold.stat +++ b/scalafmt-tests/src/test/resources/newlines/source_fold.stat @@ -4312,12 +4312,12 @@ object a { >>> object a { binder.bind("f", params) shouldBe Some(Left( - s"Cannot parse parameter f as DummyEnum, $wrongValue is not a member of Enum (dummy-value)" - )) + s"Cannot parse parameter f as DummyEnum, $wrongValue is not a member of Enum (dummy-value)" + )) when(audienceService.publish(any[Tenant], any[Int])) .thenReturn(Success[NonEmptyList[String], ApiAudience](apiAudience - .copy(status = AudienceStatus.Pending.name))) + .copy(status = AudienceStatus.Pending.name))) } <<< unsafeCallSite = Oneline, nested with one arg, several options maxColumn = 100 diff --git a/scalafmt-tests/src/test/resources/newlines/source_keep.stat b/scalafmt-tests/src/test/resources/newlines/source_keep.stat index 995d36dddd..1c4ccca13e 100644 --- a/scalafmt-tests/src/test/resources/newlines/source_keep.stat +++ b/scalafmt-tests/src/test/resources/newlines/source_keep.stat @@ -4527,12 +4527,12 @@ object a { >>> object a { binder.bind("f", params) shouldBe Some(Left( - s"Cannot parse parameter f as DummyEnum, $wrongValue is not a member of Enum (dummy-value)" - )) + s"Cannot parse parameter f as DummyEnum, $wrongValue is not a member of Enum (dummy-value)" + )) when(audienceService.publish(any[Tenant], any[Int])).thenReturn( Success[NonEmptyList[String], ApiAudience](apiAudience - .copy(status = AudienceStatus.Pending.name)) + .copy(status = AudienceStatus.Pending.name)) ) } <<< unsafeCallSite = Oneline, nested with one arg, several options diff --git a/scalafmt-tests/src/test/resources/scalajs/Apply.stat b/scalafmt-tests/src/test/resources/scalajs/Apply.stat index 636afe7284..215d124814 100644 --- a/scalafmt-tests/src/test/resources/scalajs/Apply.stat +++ b/scalafmt-tests/src/test/resources/scalajs/Apply.stat @@ -206,7 +206,7 @@ object a { >>> object a { new SimpleMethodName(new SimpleMethodName( - validateSimpleEncodedName(name, 0, len, openAngleBracketOK = false))) + validateSimpleEncodedName(name, 0, len, openAngleBracketOK = false))) } <<< #2079 avoid nested indent, always; 3 binPack.preset = true @@ -242,9 +242,9 @@ object a { >>> object a { foo(new SimpleMethodName(new SimpleMethodName(validateSimpleEncodedName(name, - 0, len, openAngleBracketOK = false))), + 0, len, openAngleBracketOK = false))), new SimpleMethodName(new SimpleMethodName(validateSimpleEncodedName(name, - 0, len, openAngleBracketOK = false)))) + 0, len, openAngleBracketOK = false)))) } <<< #2079 avoid nested indent, always; 4 binPack.preset = true @@ -273,8 +273,8 @@ object a { >>> object a { new SimpleMethodName( - new SimpleMethodName(new SimpleMethodName(validateSimpleEncodedName(name, - 0, len, openAngleBracketOK = false))) + new SimpleMethodName(new SimpleMethodName( + validateSimpleEncodedName(name, 0, len, openAngleBracketOK = false))) ).foo } <<< binpack=oneline, nested, inner with multiple args @@ -292,7 +292,7 @@ object a { object a { if (staticInitializerStats.nonEmpty) { List(genStaticConstructorWithStats(ir.Names.StaticInitializerName, - js.Block(staticInitializerStats))) + js.Block(staticInitializerStats))) } else Nil }