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 lineIdx = LineGap.lineNumberToIdx (newCursorLineNumber, buffer)
val buffer = LineGap.goToIdx (lineIdx, buffer) val buffer = LineGap.goToIdx (lineIdx, buffer)
in in
if lineIdx >= #textLength buffer then if lineIdx >= #textLength buffer - 1 then
(* we reached last line *) (* we reached last line *)
let let
val lineIdx = Int.max (#textLength buffer - 1, 0) val lineIdx = Int.max (#textLength buffer - 1, 0)
val buffer = LineGap.goToIdx (lineIdx, buffer) val buffer = LineGap.goToIdx (lineIdx, buffer)
val lineIdx =
if Cursor.isOnNewlineAfterChr (buffer, lineIdx) then lineIdx - 1
else lineIdx
val startOfLine = Cursor.vi0 (buffer, lineIdx) val startOfLine = Cursor.vi0 (buffer, lineIdx)
in in
if cursorIdx >= startOfLine then if cursorIdx >= startOfLine then
@@ -292,12 +297,6 @@ struct
finishMoveCursorUpDown finishMoveCursorUpDown
(app, newCursorLineNumber, buffer, column, startOfLine) (app, newCursorLineNumber, buffer, column, startOfLine)
end 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 else
let let
val lineIdx = val lineIdx =

View File

@@ -463,7 +463,7 @@ struct
val {cursorIdx, ...} = TestUtils.updateMany (app, "2j") val {cursorIdx, ...} = TestUtils.updateMany (app, "2j")
(* assert *) (* assert *)
val expectedIdx = initialCursorIdx val expectedIdx = 6
in in
Expect.isTrue (cursorIdx = expectedIdx) Expect.isTrue (cursorIdx = expectedIdx)
end) end)