improvements to TextWindow.isCursorVisible (no need to do binary search; in fact, that leads to an exception, because we are meant to use Vector.sub to access the relative line instead)

This commit is contained in:
2024-11-02 12:54:34 +00:00
parent 2a8e02ff3a
commit 2df8f88452
2 changed files with 11 additions and 7 deletions

View File

@@ -319,9 +319,13 @@ struct
fun startIsCursorVisible fun startIsCursorVisible
(curIdx, shd, stl, lhd, startLine, curLine, maxW, maxH, newCursorIdx) = (curIdx, shd, stl, lhd, startLine, curLine, maxW, maxH, newCursorIdx) =
if startLine = curLine then
helpIsCursorVisible
(0, shd, stl, curIdx, maxW, maxH, 0, 0, newCursorIdx)
else
let let
val relativeLine = (curLine + Vector.length lhd) - startLine val relativeLine = (curLine + Vector.length lhd) - startLine
val lineIdx = Cursor.binSearch (relativeLine, lhd) val lineIdx = Vector.sub (lhd, relativeLine)
val absIdx = curIdx + lineIdx val absIdx = curIdx + lineIdx
in in
helpIsCursorVisible helpIsCursorVisible

BIN
shf

Binary file not shown.