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

@@ -29,7 +29,10 @@ struct
Utils.getRelativeLineStartFromRightHead (startLine, curLine, lhd)
(* get absolute idx of line *)
val absIdx = curIdx + strPos
val searchPos = BinSearch.equalOrMore (absIdx, searchList)
val searchPos =
if searchPos = ~1 then Vector.length searchList else searchPos
val env = Utils.initEnv
( windowWidth

View File

@@ -60,7 +60,7 @@ struct
let
val searchPos = BinSearch.equalOrMore (pos + 1, #searchList env)
in
if searchPos = Vector.length line then
if searchPos = ~1 then
(* next line is not in this node *)
let
val absIdx = absIdx - pos

View File

@@ -75,7 +75,7 @@ struct
let
val searchPos = BinSearch.equalOrMore (pos + 1, #searchList env)
in
if searchPos = Vector.length line then
if searchPos = ~1 then
(* next line is not in this node *)
let
val absIdx = absIdx - pos