Skip to content

Commit

Permalink
Fix sequential path selector not switching between selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
ancavar committed Sep 4, 2024
1 parent c886326 commit c6331e3
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@ class SequentialPathSelector<State>(
require(selectors.size >= 2) { "Cannot create sequential path selector from less than 2 selectors" }
}

private var currentSelector = selectors.first()
private var ptr = 0

private var currentSelector = selectors[ptr]
private val totalSteps
get() = stepsStatistics.totalSteps.toUInt()

override fun isEmpty() = currentSelector.isEmpty() && selectors.all { it.isEmpty() }

override fun peek(): State {
// currently only either 1 or 2 selectors are supported
if (totalSteps == stepsToSwitch) {
selectors.drop(1)
currentSelector = selectors.first()
ptr = (ptr + 1) % selectors.size
currentSelector = selectors[ptr]
}
return currentSelector.peek()
}
Expand Down

0 comments on commit c6331e3

Please sign in to comment.