fully done amending 'getCursorColumn' in cursor.sml it seems, because all the inputs I throw at it give the expected results
This commit is contained in:
@@ -343,12 +343,7 @@ struct
|
|||||||
helpGetCursorColumnLeft (lstl, lltl, cursorIdx)
|
helpGetCursorColumnLeft (lstl, lltl, cursorIdx)
|
||||||
end
|
end
|
||||||
| (_, _) =>
|
| (_, _) =>
|
||||||
let
|
|
||||||
val _ = print "347\n"
|
|
||||||
val _ = print ("cIdx: " ^ Int.toString cursorIdx ^ "\n")
|
|
||||||
in
|
|
||||||
Int.max (cursorIdx, 0)
|
Int.max (cursorIdx, 0)
|
||||||
end
|
|
||||||
|
|
||||||
fun getCursorColumn (strIdx, strHd, lnHd, leftStrings, leftLines, cursorIdx) =
|
fun getCursorColumn (strIdx, strHd, lnHd, leftStrings, leftLines, cursorIdx) =
|
||||||
if Vector.length lnHd > 0 then
|
if Vector.length lnHd > 0 then
|
||||||
@@ -358,42 +353,45 @@ struct
|
|||||||
if firstLn > strIdx then
|
if firstLn > strIdx then
|
||||||
(* search left strings/lines *)
|
(* search left strings/lines *)
|
||||||
let
|
let
|
||||||
val _ = print "361\n"
|
|
||||||
val lineIdx =
|
val lineIdx =
|
||||||
helpGetCursorColumnLeft
|
helpGetCursorColumnLeft
|
||||||
(leftStrings, leftLines, cursorIdx - strIdx)
|
(leftStrings, leftLines, cursorIdx - strIdx)
|
||||||
in
|
in
|
||||||
cursorIdx - lineIdx
|
if lineIdx = 0 then
|
||||||
|
cursorIdx
|
||||||
|
else
|
||||||
|
cursorIdx - lineIdx - 1
|
||||||
end
|
end
|
||||||
else if firstLn < strIdx then
|
else if firstLn < strIdx then
|
||||||
(* binary search in here
|
(* binary search in here
|
||||||
* because we know lnHd definitely contains
|
* because we know lnHd definitely contains
|
||||||
* a lineIdx less or equal to strIdx *)
|
* a lineIdx less or equal to strIdx *)
|
||||||
let
|
let
|
||||||
val _ = print "373\n"
|
|
||||||
val lnIdx = binSearch (strIdx, lnHd)
|
val lnIdx = binSearch (strIdx, lnHd)
|
||||||
val lnIdx = Vector.sub (lnHd, lnIdx)
|
val lnIdx = Vector.sub (lnHd, lnIdx)
|
||||||
in
|
in
|
||||||
if lnIdx < strIdx then
|
if lnIdx < strIdx then
|
||||||
(print "378\n"; strIdx - lnIdx - 1)
|
strIdx - lnIdx - 1
|
||||||
else
|
else
|
||||||
(* firstLn = strIdx *)
|
(* firstLn = strIdx *)
|
||||||
(print "381\n";0)
|
0
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
(* firstLn = strIdx
|
(* firstLn = strIdx
|
||||||
* meaning that we are already at a line break
|
* meaning that we are already at a line break
|
||||||
* and that the column is 0 *)
|
* and that the column is 0 *)
|
||||||
(print "387\n";0)
|
0
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
let
|
let
|
||||||
val _ = print "391\n"
|
|
||||||
val lineIdx =
|
val lineIdx =
|
||||||
helpGetCursorColumnLeft
|
helpGetCursorColumnLeft
|
||||||
(leftStrings, leftLines, cursorIdx - strIdx)
|
(leftStrings, leftLines, cursorIdx - strIdx)
|
||||||
in
|
in
|
||||||
cursorIdx - lineIdx
|
if lineIdx = 0 then
|
||||||
|
cursorIdx
|
||||||
|
else
|
||||||
|
cursorIdx - lineIdx - 1
|
||||||
end
|
end
|
||||||
|
|
||||||
fun helpViJ
|
fun helpViJ
|
||||||
|
|||||||
Reference in New Issue
Block a user