begin refactoring to let cursor move to very last char of file (including unix line ending)

This commit is contained in:
2025-09-23 10:50:10 +01:00
parent 8931d4d071
commit 961ce63023
5 changed files with 13 additions and 27 deletions

View File

@@ -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