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

BestFirstSearch: allow block close go past range #4541

Merged
merged 1 commit into from
Nov 13, 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 @@ -36,13 +36,11 @@ private class BestFirstSearch private (range: Set[Range])(implicit

var stats = new StateStats(tokens, initStyle.runner)

private def getBlockCloseToRecurse(ft: FT, stop: T)(implicit
private def getBlockCloseToRecurse(ft: FT)(implicit
style: ScalafmtConfig,
): Option[T] = getEndOfBlock(ft, parensToo = true).collect {
case close if close.left != stop && {
// Block must span at least 3 lines to be worth recursing.
tokens.width(ft, close) > style.maxColumn * 3
} => close.left
// Block must span at least 3 lines to be worth recursing.
case close if tokens.width(ft, close) > style.maxColumn * 3 => close.left
}

private val memo = mutable.Map.empty[Long, Option[State]]
Expand Down Expand Up @@ -111,7 +109,7 @@ private class BestFirstSearch private (range: Set[Range])(implicit
noOptZoneOrBlock.isEmpty || !optimizer.recurseOnBlocks
val blockCloseState =
if (noBlockClose) None
else getBlockCloseToRecurse(splitToken, stop)
else getBlockCloseToRecurse(splitToken)
.flatMap(shortestPathMemo(curr, _, depth + 1, isOpt))
if (blockCloseState.nonEmpty) blockCloseState
.foreach(_.foreach(Q.enqueue))
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(40783820)
override protected def totalStatesVisited: Option[Int] = Some(40783579)

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(44103702)
override protected def totalStatesVisited: Option[Int] = Some(44102882)

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

Expand Down
Loading