begin refactoring to let cursor move to very last char of file (including unix line ending)
This commit is contained in:
@@ -64,7 +64,7 @@ struct
|
||||
|
||||
val textLength = #textLength buffer
|
||||
val cursorIdx =
|
||||
if cursorIdx >= textLength - 2 then Int.max (textLength - 2, 0)
|
||||
if cursorIdx >= textLength - 1 then Int.max (textLength - 1, 0)
|
||||
else cursorIdx
|
||||
in
|
||||
NormalFinish.buildTextAndClear
|
||||
|
||||
@@ -65,7 +65,7 @@ struct
|
||||
val buffer = LineGap.goToEnd buffer
|
||||
val {line = bufferLine, textLength, ...} = buffer
|
||||
|
||||
val bufferIdx = Int.max (0, textLength - 2)
|
||||
val bufferIdx = Int.max (0, textLength - 1)
|
||||
val bufferLine = bufferLine - 1
|
||||
|
||||
val buffer = LineGap.goToIdx (bufferIdx, buffer)
|
||||
@@ -124,8 +124,8 @@ struct
|
||||
val buffer = LineGap.goToIdx (lineIdx, buffer)
|
||||
val endOfLineIdx = Cursor.viDlr (buffer, lineIdx, 1)
|
||||
val endOfLineIdx =
|
||||
if endOfLineIdx >= #textLength buffer - 2 then
|
||||
Int.max (0, #textLength buffer - 2)
|
||||
if endOfLineIdx >= #textLength buffer - 1 then
|
||||
Int.max (0, #textLength buffer - 1)
|
||||
else
|
||||
endOfLineIdx
|
||||
|
||||
@@ -256,8 +256,8 @@ struct
|
||||
val lineIdx = Cursor.vi0 (buffer, lineIdx)
|
||||
|
||||
val lineIdx =
|
||||
if lineIdx >= #textLength buffer - 2 then
|
||||
Int.max (0, #textLength buffer - 2)
|
||||
if lineIdx >= #textLength buffer - 1 then
|
||||
Int.max (0, #textLength buffer - 1)
|
||||
else
|
||||
lineIdx
|
||||
in
|
||||
|
||||
@@ -3,11 +3,6 @@ struct
|
||||
structure TC = TextConstants
|
||||
structure Utils = TextBuilderUtils
|
||||
|
||||
fun isSecondLastChr (pos, str, tl) =
|
||||
case tl of
|
||||
[] => pos = String.size str - 2
|
||||
| _ => false
|
||||
|
||||
fun goToFirstLineAfter
|
||||
(stl, ltl, posY, lineNumber, absIdx, cursorIdx, env, acc) =
|
||||
case (stl, ltl) of
|
||||
@@ -140,11 +135,6 @@ struct
|
||||
#"\n" =>
|
||||
if lineNumber + 1 > #lastLineNumber env then
|
||||
acc
|
||||
else if isSecondLastChr (pos, str, stl) then
|
||||
if absIdx = cursorIdx then
|
||||
Utils.makeCursor (#startX env, posY + TC.ySpace, env) :: acc
|
||||
else
|
||||
acc
|
||||
else
|
||||
let
|
||||
val acc =
|
||||
|
||||
@@ -237,11 +237,6 @@ struct
|
||||
| #"\n" =>
|
||||
if lineNumber + 1 > #lastLineNumber env then
|
||||
acc
|
||||
else if isSecondLastChr (pos, str, stl) then
|
||||
if absIdx = cursorIdx then
|
||||
Utils.makeCursor (#startX env, posY + TC.ySpace, env) :: acc
|
||||
else
|
||||
acc
|
||||
else
|
||||
let
|
||||
val acc =
|
||||
|
||||
Reference in New Issue
Block a user