Skip to content

Commit

Permalink
Router: slightly penalize interpolation newlines
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Oct 14, 2024
1 parent 4ff11e8 commit 2559975
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,18 @@ class Router(formatOps: FormatOps) {
else s.copy(optimalAt = None)
}
}
else Policy ?
(style.newlines.sourceIgnored || isTripleQuote(m.left.text)) ||
else if (!style.newlines.sourceIgnored && !isTripleQuote(m.left.text))
Policy.on(end, "INTERP-KEEP-NONL") {
case Decision(x, ss) if x.noBreak =>
ss.map(s => if (s.isNL) s.withPenalty(penalty) else s)
}
else Policy ?
(style.newlines.inInterpolation eq
Newlines.InInterpolation.allow) &&
Policy.on(end, "INTERP-ALLOW-NL", rank = -1) {
case Decision(_, ss) => ss
.map(s => if (s.isNL) s.withPenalty(1) else s)
}
}
val split = Split(NoSplit, 0, policy = policy)
val alignIndents =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ abstract class CommunityIntellijScalaSuite(name: String)
class CommunityIntellijScala_2024_2_Suite
extends CommunityIntellijScalaSuite("intellij-scala-2024.2") {

override protected def totalStatesVisited: Option[Int] = Some(48186930)
override protected def totalStatesVisited: Option[Int] = Some(48190466)

override protected def builds = Seq(getBuild(
"2024.2.28",
Expand Down Expand Up @@ -51,7 +51,7 @@ class CommunityIntellijScala_2024_2_Suite
class CommunityIntellijScala_2024_3_Suite
extends CommunityIntellijScalaSuite("intellij-scala-2024.3") {

override protected def totalStatesVisited: Option[Int] = Some(48366702)
override protected def totalStatesVisited: Option[Int] = Some(48370242)

override protected def builds = Seq(getBuild(
"2024.3.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ abstract class CommunityScala2Suite(name: String)

class CommunityScala2_12Suite extends CommunityScala2Suite("scala-2.12") {

override protected def totalStatesVisited: Option[Int] = Some(35850116)
override protected def totalStatesVisited: Option[Int] = Some(35856475)

override protected def builds =
Seq(getBuild("v2.12.20", dialects.Scala212, 1277))
Expand All @@ -18,7 +18,7 @@ class CommunityScala2_12Suite extends CommunityScala2Suite("scala-2.12") {

class CommunityScala2_13Suite extends CommunityScala2Suite("scala-2.13") {

override protected def totalStatesVisited: Option[Int] = Some(44610131)
override protected def totalStatesVisited: Option[Int] = Some(44618135)

override protected def builds =
Seq(getBuild("v2.13.14", dialects.Scala213, 1287))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ abstract class CommunityScala3Suite(name: String)

class CommunityScala3_2Suite extends CommunityScala3Suite("scala-3.2") {

override protected def totalStatesVisited: Option[Int] = Some(33372940)
override protected def totalStatesVisited: Option[Int] = Some(33385186)

override protected def builds = Seq(getBuild("3.2.2", dialects.Scala32, 791))

}

class CommunityScala3_3Suite extends CommunityScala3Suite("scala-3.3") {

override protected def totalStatesVisited: Option[Int] = Some(36020956)
override protected def totalStatesVisited: Option[Int] = Some(36033019)

override protected def builds = Seq(getBuild("3.3.3", dialects.Scala33, 861))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ abstract class CommunitySparkSuite(name: String)

class CommunitySpark3_4Suite extends CommunitySparkSuite("spark-3.4") {

override protected def totalStatesVisited: Option[Int] = Some(72459436)
override protected def totalStatesVisited: Option[Int] = Some(72480315)

override protected def builds =
Seq(getBuild("v3.4.1", dialects.Scala213, 2585))
Expand All @@ -18,7 +18,7 @@ class CommunitySpark3_4Suite extends CommunitySparkSuite("spark-3.4") {

class CommunitySpark3_5Suite extends CommunitySparkSuite("spark-3.5") {

override protected def totalStatesVisited: Option[Int] = Some(76628137)
override protected def totalStatesVisited: Option[Int] = Some(76649844)

override protected def builds =
Seq(getBuild("v3.5.3", dialects.Scala213, 2756))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9821,8 +9821,8 @@ object a {
}
>>>
object a {
options.common.debug.print(s"Files to be formatted:\n${projectFiles
.mkString("\n")}\n")
options.common.debug.print(s"Files to be formatted:\n${projectFiles
.mkString("\n")}\n")
options.common.debug
.print(s"Files to be formatted:\n${projectFiles.mkString("\n")}\n")
options.common.debug
.print(s"Files to be formatted:\n${projectFiles.mkString("\n")}\n")
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class FormatTests extends FunSuite with CanRunTests with FormatAssertions {
val explored = Debug.explored.get()
logger.debug(s"Total explored: $explored")
if (!onlyUnit && !onlyManual)
assertEquals(explored, 1496129, "total explored")
assertEquals(explored, 1496399, "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

0 comments on commit 2559975

Please sign in to comment.