Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Router: increase NL penalty within interpolation #4068

Merged
merged 2 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
75 changes: 75 additions & 0 deletions scalafmt-tests/src/test/resources/default/String.stat
Original file line number Diff line number Diff line change
Expand Up @@ -630,3 +630,78 @@ println(
|A very long string
|with multiple lines
|""".stripMargin)
<<< #4067 avoid classic
preset = default
maxColumn = 120
newlines {
inInterpolation = avoid
}
===
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)}"
)
}
>>>
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)}"
)
}
<<< #4067 avoid keep
preset = default
maxColumn = 120
newlines {
inInterpolation = avoid
source = keep
}
===
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)}"
)
}
>>>
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)}"
)
}
<<< #4067 avoid fold
preset = default
maxColumn = 120
newlines {
inInterpolation = avoid
source = fold
}
===
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)}"
)
}
>>>
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)}"
)
}
<<< #4067 avoid unfold
preset = default
maxColumn = 120
newlines {
inInterpolation = avoid
source = unfold
}
===
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)}"
)
}
>>>
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)}"
)
}
Loading