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 262b855c72..a00df806f7 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 @@ -1497,6 +1497,11 @@ class Router(formatOps: FormatOps) { Split(Space, 0), Split(Newline, 1).withIndent(indent, right, After) ) + case _: Defn.RepeatedEnumCase if { + if (!style.newlines.sourceIgnored) newlines != 0 + else style.newlines.source eq Newlines.unfold + } => + Seq(Split(Newline, 0)) case _ => Seq( Split(Space, 0), diff --git a/scalafmt-tests/src/test/resources/scala3/OptionalBraces.stat b/scalafmt-tests/src/test/resources/scala3/OptionalBraces.stat index 0a52ea28b1..6cc0f81129 100644 --- a/scalafmt-tests/src/test/resources/scala3/OptionalBraces.stat +++ b/scalafmt-tests/src/test/resources/scala3/OptionalBraces.stat @@ -3330,9 +3330,12 @@ enum SerializedField extends jl.Enum[SerializedField] { case UNKNOWN, // represents a field code we didn't recognize END_MARKER, // end of a list of fields ROOT_VALUE, // Fields at the root - ROOT_WAS_CONFIG, VALUE_DATA, // Fields that make up a value - VALUE_ORIGIN, ORIGIN_DESCRIPTION, // Fields that make up an origin - ORIGIN_LINE_NUMBER, ORIGIN_END_LINE_NUMBER, ORIGIN_TYPE, ORIGIN_URL, + ROOT_WAS_CONFIG, + VALUE_DATA, // Fields that make up a value + VALUE_ORIGIN, + ORIGIN_DESCRIPTION, // Fields that make up an origin + ORIGIN_LINE_NUMBER, + ORIGIN_END_LINE_NUMBER, ORIGIN_TYPE, ORIGIN_URL, ORIGIN_COMMENTS, ORIGIN_NULL_URL, ORIGIN_NULL_COMMENTS, ORIGIN_RESOURCE, ORIGIN_NULL_RESOURCE } diff --git a/scalafmt-tests/src/test/resources/scala3/OptionalBraces_keep.stat b/scalafmt-tests/src/test/resources/scala3/OptionalBraces_keep.stat index 9f2cfa0191..83e98437c1 100644 --- a/scalafmt-tests/src/test/resources/scala3/OptionalBraces_keep.stat +++ b/scalafmt-tests/src/test/resources/scala3/OptionalBraces_keep.stat @@ -3319,9 +3319,12 @@ enum SerializedField extends jl.Enum[SerializedField] { case UNKNOWN, // represents a field code we didn't recognize END_MARKER, // end of a list of fields ROOT_VALUE, // Fields at the root - ROOT_WAS_CONFIG, VALUE_DATA, // Fields that make up a value - VALUE_ORIGIN, ORIGIN_DESCRIPTION, // Fields that make up an origin - ORIGIN_LINE_NUMBER, ORIGIN_END_LINE_NUMBER, ORIGIN_TYPE, ORIGIN_URL, + ROOT_WAS_CONFIG, + VALUE_DATA, // Fields that make up a value + VALUE_ORIGIN, + ORIGIN_DESCRIPTION, // Fields that make up an origin + ORIGIN_LINE_NUMBER, + ORIGIN_END_LINE_NUMBER, ORIGIN_TYPE, ORIGIN_URL, ORIGIN_COMMENTS, ORIGIN_NULL_URL, ORIGIN_NULL_COMMENTS, ORIGIN_RESOURCE, ORIGIN_NULL_RESOURCE } diff --git a/scalafmt-tests/src/test/resources/scala3/OptionalBraces_unfold.stat b/scalafmt-tests/src/test/resources/scala3/OptionalBraces_unfold.stat index ce83db092c..5cc2c06cc3 100644 --- a/scalafmt-tests/src/test/resources/scala3/OptionalBraces_unfold.stat +++ b/scalafmt-tests/src/test/resources/scala3/OptionalBraces_unfold.stat @@ -3421,9 +3421,17 @@ enum SerializedField extends jl.Enum[SerializedField] { case UNKNOWN, // represents a field code we didn't recognize END_MARKER, // end of a list of fields ROOT_VALUE, // Fields at the root - ROOT_WAS_CONFIG, VALUE_DATA, // Fields that make up a value - VALUE_ORIGIN, ORIGIN_DESCRIPTION, // Fields that make up an origin - ORIGIN_LINE_NUMBER, ORIGIN_END_LINE_NUMBER, ORIGIN_TYPE, ORIGIN_URL, - ORIGIN_COMMENTS, ORIGIN_NULL_URL, ORIGIN_NULL_COMMENTS, ORIGIN_RESOURCE, + ROOT_WAS_CONFIG, + VALUE_DATA, // Fields that make up a value + VALUE_ORIGIN, + ORIGIN_DESCRIPTION, // Fields that make up an origin + ORIGIN_LINE_NUMBER, + ORIGIN_END_LINE_NUMBER, + ORIGIN_TYPE, + ORIGIN_URL, + ORIGIN_COMMENTS, + ORIGIN_NULL_URL, + ORIGIN_NULL_COMMENTS, + ORIGIN_RESOURCE, ORIGIN_NULL_RESOURCE }