Skip to content

Commit

Permalink
BestFirstSearch: fix bug, possible infinite loop
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Sep 20, 2024
1 parent 7b98a6c commit 4022f2f
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,15 +280,16 @@ private class BestFirstSearch private (range: Set[Range])(implicit
case Seq(split) if !split.isNL =>
style.runner.event(FormatEvent.Enqueue(split))
val nextState = state.next(split, nextAllAltAreNL = false)
if (nextState.split.cost > 0 || nextState.depth >= tokens.length) state
if (nextState.split.cost > 0) state
else if (nextState.depth >= tokens.length) nextState
else {
val nextToken = tokens(nextState.depth)
if (RightParenOrBracket(nextToken.right)) {
implicit val style: ScalafmtConfig = styleMap.at(nextToken)
trackState(nextState, depth, 0)
val nextSplits = getActiveSplits(nextToken, state, maxCost = 0)
val nextSplits = getActiveSplits(nextToken, nextState, maxCost = 0)
traverseSameLineZeroCost(nextSplits, nextState, depth)
} else state
} else nextState
}
case _ => state
}
Expand Down

0 comments on commit 4022f2f

Please sign in to comment.