pass failing test for 'dj' motion through a different startLine calculation depending on whether cursor is already on a newline or not

This commit is contained in:
2025-09-25 06:34:08 +01:00
parent cddd03812b
commit 1000e74183
2 changed files with 11 additions and 3 deletions

View File

@@ -391,7 +391,11 @@ struct
val startIdx = Cursor.vi0 (buffer, cursorIdx) val startIdx = Cursor.vi0 (buffer, cursorIdx)
val buffer = LineGap.goToIdx (startIdx, buffer) val buffer = LineGap.goToIdx (startIdx, buffer)
val startLine = LineGap.idxToLineNumber (cursorIdx + 1, buffer) val startLine =
if Cursor.isCursorAtStartOfLine (buffer, startIdx) then
LineGap.idxToLineNumber (startIdx, buffer)
else
LineGap.idxToLineNumber (startIdx + 1, buffer)
val endLine = startLine + count val endLine = startLine + count
val buffer = LineGap.goToLine (endLine, buffer) val buffer = LineGap.goToLine (endLine, buffer)
@@ -417,7 +421,11 @@ struct
val startIdx = Cursor.vi0 (buffer, cursorIdx) val startIdx = Cursor.vi0 (buffer, cursorIdx)
val buffer = LineGap.goToIdx (startIdx, buffer) val buffer = LineGap.goToIdx (startIdx, buffer)
val startLine = LineGap.idxToLineNumber (cursorIdx + 1, buffer) val startLine =
if Cursor.isCursorAtStartOfLine (buffer, startIdx) then
LineGap.idxToLineNumber (startIdx, buffer)
else
LineGap.idxToLineNumber (startIdx + 1, buffer)
val endLine = startLine + count + 1 val endLine = startLine + count + 1
val buffer = LineGap.goToLine (endLine, buffer) val buffer = LineGap.goToLine (endLine, buffer)

View File

@@ -439,7 +439,7 @@ struct
, test "deletes two lines when cursor is on a newline" (fn _ => , test "deletes two lines when cursor is on a newline" (fn _ =>
let let
(* arrange *) (* arrange *)
val originalString = "\nhello\nworld\ntrello\brillo\n" val originalString = "\nhello\nworld\ntrello\nbrillo\n"
val originalIdx = 0 val originalIdx = 0
val app = TestUtils.init originalString val app = TestUtils.init originalString