remove references to 'Cursor.clipIdx' and delete that function once it is no longer used
This commit is contained in:
@@ -1251,38 +1251,4 @@ struct
|
|||||||
end
|
end
|
||||||
| [] => true
|
| [] => true
|
||||||
end
|
end
|
||||||
|
|
||||||
(* Prerequisite: lineGap is moved to cursorIdx *)
|
|
||||||
fun clipIdx (lineGap: LineGap.t, cursorIdx) =
|
|
||||||
let
|
|
||||||
val {rightStrings, idx = bufferIdx, ...} = lineGap
|
|
||||||
in
|
|
||||||
(* We are trying to check if cursorIdx is within the buffer. *)
|
|
||||||
case rightStrings of
|
|
||||||
_ :: _ :: _ =>
|
|
||||||
(* if there is a string after the hd,
|
|
||||||
* we are definitely in a valid idx and should return it *)
|
|
||||||
cursorIdx
|
|
||||||
| [hd] =>
|
|
||||||
let
|
|
||||||
val strIdx = cursorIdx - bufferIdx
|
|
||||||
in
|
|
||||||
if strIdx < String.size hd - 1 then
|
|
||||||
(* if we are before the last char in the string.
|
|
||||||
* Unix file endings always have \n at the end
|
|
||||||
* but we do not want cursor to ever go to end
|
|
||||||
* as vi also does not go to the very end.
|
|
||||||
* This is why we check strIdx is before the last char.
|
|
||||||
* *)
|
|
||||||
cursorIdx
|
|
||||||
else
|
|
||||||
(* if end of buffer - 2 is greater than 0, then that;
|
|
||||||
* else, 0 *)
|
|
||||||
Int.max (bufferIdx + String.size hd - 2, 0)
|
|
||||||
end
|
|
||||||
| [] =>
|
|
||||||
(* if end of buffer - 2 is greater than 0, then that;
|
|
||||||
* else, 0 *)
|
|
||||||
Int.max (bufferIdx - 2, 0)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -164,7 +164,11 @@ struct
|
|||||||
let
|
let
|
||||||
val low = Int.min (cursorIdx, otherIdx)
|
val low = Int.min (cursorIdx, otherIdx)
|
||||||
val high = Int.max (cursorIdx, otherIdx)
|
val high = Int.max (cursorIdx, otherIdx)
|
||||||
val high = Cursor.clipIdx (buffer, high)
|
val high =
|
||||||
|
if high >= #textLength buffer - 2 then
|
||||||
|
Int.max (#textLength buffer - 2, 0)
|
||||||
|
else
|
||||||
|
high
|
||||||
val length = high - low
|
val length = high - low
|
||||||
|
|
||||||
val buffer = LineGap.goToIdx (high, buffer)
|
val buffer = LineGap.goToIdx (high, buffer)
|
||||||
@@ -183,7 +187,11 @@ struct
|
|||||||
* is no longer a valid idx,
|
* is no longer a valid idx,
|
||||||
* clip cursorIdx to the end. *)
|
* clip cursorIdx to the end. *)
|
||||||
val buffer = LineGap.goToIdx (low, buffer)
|
val buffer = LineGap.goToIdx (low, buffer)
|
||||||
val cursorIdx = Cursor.clipIdx (buffer, low)
|
val cursorIdx =
|
||||||
|
if low >= #textLength buffer then
|
||||||
|
Int.max (#textLength buffer - 2, low)
|
||||||
|
else
|
||||||
|
low
|
||||||
in
|
in
|
||||||
NormalFinish.buildTextAndClear
|
NormalFinish.buildTextAndClear
|
||||||
(app, buffer, cursorIdx, searchList, initialMsg, time)
|
(app, buffer, cursorIdx, searchList, initialMsg, time)
|
||||||
|
|||||||
Reference in New Issue
Block a user