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: remove optimal if avoid interpolation NL #4423

Merged
merged 1 commit into from
Oct 9, 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 @@ -80,7 +80,13 @@ class Router(formatOps: FormatOps) {
val policy = {
val penalty = BreakSingleLineInterpolatedString
if (style.newlines.inInterpolation eq Newlines.InInterpolation.avoid)
PenalizeAllNewlines(end, penalty)
Policy.on(end, "INTERP-AVOID-NL", rank = -1) {
case Decision(_, ss) => ss.map { s =>
if (s.isNL) s.withPenalty(penalty)
else if (s.optimalAt.isEmpty) s
else s.copy(optimalAt = None)
}
}
else Policy ?
(style.newlines.sourceIgnored || isTripleQuote(m.left.text)) ||
Policy.on(end, "INTERP-KEEP-NONL") {
Expand Down Expand Up @@ -1739,10 +1745,7 @@ class Router(formatOps: FormatOps) {
}
def shouldKillOnFail() =
(style.binPack.callSite ne BinPack.Site.Never) &&
(!(prevSelect.isEmpty && nextSelect.isEmpty) &&
findTreeWithParentSimple(expireTree) {
_.isAny[Term.Interpolate, Pat.Interpolate]
}.isEmpty || isInfixArg(expireTree))
isInfixArg(expireTree)

val ftAfterRight = tokens(ft, 2)
val baseSplits = style.newlines.getSelectChains match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class FormatTests extends FunSuite with CanRunTests with FormatAssertions {
override def afterAll(): Unit = {
logger.debug(s"Total explored: ${Debug.explored}")
if (!onlyUnit && !onlyManual)
assertEquals(Debug.explored, 1777121, "total explored")
assertEquals(Debug.explored, 1777089, "total explored")
val results = debugResults.result()
// TODO(olafur) don't block printing out test results.
// I don't want to deal with scalaz's Tasks :'(
Expand Down
Loading