pass all tests for 'j' motion

This commit is contained in:
2025-09-23 15:30:28 +01:00
parent 95a4f109bd
commit 9a15b1715a
2 changed files with 7 additions and 8 deletions

View File

@@ -277,11 +277,16 @@ struct
val lineIdx = LineGap.lineNumberToIdx (newCursorLineNumber, buffer)
val buffer = LineGap.goToIdx (lineIdx, buffer)
in
if lineIdx >= #textLength buffer then
if lineIdx >= #textLength buffer - 1 then
(* we reached last line *)
let
val lineIdx = Int.max (#textLength buffer - 1, 0)
val buffer = LineGap.goToIdx (lineIdx, buffer)
val lineIdx =
if Cursor.isOnNewlineAfterChr (buffer, lineIdx) then lineIdx - 1
else lineIdx
val startOfLine = Cursor.vi0 (buffer, lineIdx)
in
if cursorIdx >= startOfLine then
@@ -292,12 +297,6 @@ struct
finishMoveCursorUpDown
(app, newCursorLineNumber, buffer, column, startOfLine)
end
else if lineIdx = #textLength buffer - 1 then
(* last line in buffer ends with \n
* and we just reached it *)
let val () = print "296\n"
in raise Fail ""
end
else
let
val lineIdx =