minor fix in Cursor.viH: if strIdx is not in hd of rightStrings, check tl of rightStrings
This commit is contained in:
@@ -244,33 +244,30 @@ struct
|
|||||||
cursorIdx - 1
|
cursorIdx - 1
|
||||||
| [] => 0)
|
| [] => 0)
|
||||||
|
|
||||||
(* Prerequisite: lineGap is moved to requested idx first
|
(* Prerequisite: lineGap is moved to requested idx first. *)
|
||||||
* Implementation is mostly the same as the viL function,
|
|
||||||
* except we focus on decrementing instead,
|
|
||||||
* and we examing leftStrings list instead of tail of rightStrings
|
|
||||||
* if head of rightStrings is empty or does not have the idx we want.
|
|
||||||
* todo: check if we are in a \r\n pair, but this is not a priority *)
|
|
||||||
fun viH (lineGap: LineGap.t, cursorIdx) =
|
fun viH (lineGap: LineGap.t, cursorIdx) =
|
||||||
let
|
let
|
||||||
val {rightStrings, leftStrings, idx = bufferIdx, ...} = lineGap
|
val {rightStrings, leftStrings, idx = bufferIdx, ...} = lineGap
|
||||||
in
|
in
|
||||||
case rightStrings of
|
case rightStrings of
|
||||||
hd :: _ =>
|
hd :: tl =>
|
||||||
let
|
let
|
||||||
(* convert absolute cursorIdx to idx relative to hd string *)
|
(* convert absolute cursorIdx to idx relative to hd string *)
|
||||||
val strIdx = cursorIdx - bufferIdx
|
val strIdx = cursorIdx - bufferIdx
|
||||||
in
|
in
|
||||||
if strIdx < String.size hd then
|
if strIdx < String.size hd then
|
||||||
|
(* strIdx in hd *)
|
||||||
helpViH (strIdx, hd, cursorIdx, leftStrings)
|
helpViH (strIdx, hd, cursorIdx, leftStrings)
|
||||||
else
|
else
|
||||||
(case leftStrings of
|
(* strIdx in tl *)
|
||||||
lhd :: ltl =>
|
(case tl of
|
||||||
|
tlhd :: tltl =>
|
||||||
let
|
let
|
||||||
val strIdx = strIdx - String.size hd
|
val strIdx = strIdx - String.size hd
|
||||||
in
|
in
|
||||||
helpViH (strIdx, lhd, cursorIdx, ltl)
|
helpViH (strIdx, tllhd, cursorIdx, hd :: leftStrings)
|
||||||
end
|
end
|
||||||
| [] => 0)
|
| [] => cursorIdx)
|
||||||
end
|
end
|
||||||
| [] => cursorIdx
|
| [] => cursorIdx
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user