in BinSearch.equalOrMore and BinSearch.equalOrLess, return ~1 if no item is found, for the sake of less ambiguity in usage. Functions that call these have also been adapted.

This commit is contained in:
2025-09-13 02:18:14 +01:00
parent 53a4265b07
commit 20a542df29
6 changed files with 17 additions and 7 deletions

View File

@@ -262,7 +262,7 @@ struct
else
let
val pos = BinSearch.equalOrMore (cursorIdx + 1, searchList)
val pos = if pos < Vector.length searchList then pos else 0
val pos = if pos = ~1 then 0 else pos
val count = count - 1
in
loopNextMatch (pos, searchList, count)
@@ -286,7 +286,7 @@ struct
else
let
val pos = BinSearch.equalOrLess (cursorIdx - 1, searchList)
val pos = if pos < 0 then Vector.length searchList - 1 else pos
val pos = if pos = ~1 then Vector.length searchList - 1 else pos
val count = count - 1
in
loopPrevMatch (pos, searchList, count)