From db27def29e77d594b6785503833943b8d7ec439d Mon Sep 17 00:00:00 2001 From: Albert Meltzer <7529386+kitbellew@users.noreply.github.com> Date: Wed, 19 Jun 2024 09:43:45 -0700 Subject: [PATCH] Router: increase NL penalty within interpolation --- .../src/main/scala/org/scalafmt/internal/Router.scala | 2 +- scalafmt-tests/src/test/resources/default/String.stat | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) 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 7c1fe8ef2d..651587f5f2 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 @@ -31,7 +31,7 @@ object Constants { val BracketPenalty = 20 val ExceedColumnPenalty = 1000 // Breaking a line like s"aaaaaaa${111111 + 22222}" should be last resort. - val BreakSingleLineInterpolatedString = 10 * ExceedColumnPenalty + val BreakSingleLineInterpolatedString = 1000 * ExceedColumnPenalty } /** Assigns splits to format tokens. diff --git a/scalafmt-tests/src/test/resources/default/String.stat b/scalafmt-tests/src/test/resources/default/String.stat index 870ce8e6bd..66782430ec 100644 --- a/scalafmt-tests/src/test/resources/default/String.stat +++ b/scalafmt-tests/src/test/resources/default/String.stat @@ -664,8 +664,7 @@ object a { >>> object a { throw new Exception( - s"Can't create a new SpecialThingamer when forwarding without specialUserId/specialDetails. SpecialUserID: ${x - .maybeSpecialUserId}, Special details count: ${maybeSpecialDetails.map(_.length).getOrElse(0)}" + s"Can't create a new SpecialThingamer when forwarding without specialUserId/specialDetails. SpecialUserID: ${x.maybeSpecialUserId}, Special details count: ${maybeSpecialDetails.map(_.length).getOrElse(0)}" ) } <<< #4067 avoid fold @@ -684,8 +683,7 @@ object a { >>> object a { throw new Exception( - s"Can't create a new SpecialThingamer when forwarding without specialUserId/specialDetails. SpecialUserID: ${x - .maybeSpecialUserId}, Special details count: ${maybeSpecialDetails.map(_.length).getOrElse(0)}" + s"Can't create a new SpecialThingamer when forwarding without specialUserId/specialDetails. SpecialUserID: ${x.maybeSpecialUserId}, Special details count: ${maybeSpecialDetails.map(_.length).getOrElse(0)}" ) } <<< #4067 avoid unfold @@ -704,7 +702,6 @@ object a { >>> object a { throw new Exception( - s"Can't create a new SpecialThingamer when forwarding without specialUserId/specialDetails. SpecialUserID: ${x - .maybeSpecialUserId}, Special details count: ${maybeSpecialDetails.map(_.length).getOrElse(0)}" + s"Can't create a new SpecialThingamer when forwarding without specialUserId/specialDetails. SpecialUserID: ${x.maybeSpecialUserId}, Special details count: ${maybeSpecialDetails.map(_.length).getOrElse(0)}" ) }