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:
@@ -319,14 +319,18 @@ struct
|
|||||||
|
|
||||||
fun startIsCursorVisible
|
fun startIsCursorVisible
|
||||||
(curIdx, shd, stl, lhd, startLine, curLine, maxW, maxH, newCursorIdx) =
|
(curIdx, shd, stl, lhd, startLine, curLine, maxW, maxH, newCursorIdx) =
|
||||||
let
|
if startLine = curLine then
|
||||||
val relativeLine = (curLine + Vector.length lhd) - startLine
|
|
||||||
val lineIdx = Cursor.binSearch (relativeLine, lhd)
|
|
||||||
val absIdx = curIdx + lineIdx
|
|
||||||
in
|
|
||||||
helpIsCursorVisible
|
helpIsCursorVisible
|
||||||
(lineIdx, shd, stl, absIdx, maxW, maxH, 0, 0, newCursorIdx)
|
(0, shd, stl, curIdx, maxW, maxH, 0, 0, newCursorIdx)
|
||||||
end
|
else
|
||||||
|
let
|
||||||
|
val relativeLine = (curLine + Vector.length lhd) - startLine
|
||||||
|
val lineIdx = Vector.sub (lhd, relativeLine)
|
||||||
|
val absIdx = curIdx + lineIdx
|
||||||
|
in
|
||||||
|
helpIsCursorVisible
|
||||||
|
(lineIdx, shd, stl, absIdx, maxW, maxH, 0, 0, newCursorIdx)
|
||||||
|
end
|
||||||
|
|
||||||
(* Prerequisite: move LineGap.t to startLine *)
|
(* Prerequisite: move LineGap.t to startLine *)
|
||||||
fun isCursorVisible (lineGap: LineGap.t, newCursorIdx, startLine, maxW, maxH) =
|
fun isCursorVisible (lineGap: LineGap.t, newCursorIdx, startLine, maxW, maxH) =
|
||||||
|
|||||||
Reference in New Issue
Block a user