From e24230834eee4cdc659e829eb26d8ebf78044814 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Thu, 25 Sep 2025 04:56:25 +0100 Subject: [PATCH] rename existing 'MakeNormalDelete.deleteLine' function to 'MakeNormalDelete.deleteLineDown', make 'dj' and 'ydj' commands use the renamed function, and add a new 'MakeNormalDelete.deleteLine' function (which has no implementation yet). We do this because we want to distinguish between 'dd' and 'dj' commands, allowing 'dd' to delete to the end of the file despite any count, while stoppinhg 'dj' from deleting the file when on the last line. --- fcore/normal-mode/make-normal-delete.sml | 6 ++++-- fcore/normal-mode/normal-mode.sml | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/fcore/normal-mode/make-normal-delete.sml b/fcore/normal-mode/make-normal-delete.sml index 7fd438a..041a8e9 100644 --- a/fcore/normal-mode/make-normal-delete.sml +++ b/fcore/normal-mode/make-normal-delete.sml @@ -343,7 +343,9 @@ struct end end - fun deleteLine (app: app_type, count, time) = + fun deleteLine (app: app_type, count, time) = raise Fail "todo: reimplement" + + fun deleteLineDown (app: app_type, count, time) = let val {buffer, cursorIdx, searchString, ...} = app val buffer = LineGap.goToIdx (cursorIdx, buffer) @@ -356,7 +358,7 @@ struct LineGap.idxToLineNumber (cursorIdx + 1, buffer) else LineGap.idxToLineNumber (cursorIdx + 1, buffer) - val endLine = startLine + count + val endLine = startLine + count + 1 val buffer = LineGap.goToLine (endLine, buffer) val endLineIdx = LineGap.lineNumberToIdx (endLine, buffer) diff --git a/fcore/normal-mode/normal-mode.sml b/fcore/normal-mode/normal-mode.sml index e8268a7..434732a 100644 --- a/fcore/normal-mode/normal-mode.sml +++ b/fcore/normal-mode/normal-mode.sml @@ -256,7 +256,7 @@ struct * but 'dj' or 'dk' delete whole lines * so their implementation differs from * other cursor motions *) - | #"j" => NormalDelete.deleteLine (app, count + 1, time) + | #"j" => NormalDelete.deleteLineDown (app, count, time) | #"k" => NormalDelete.deleteLineBack (app, count, time) | #"w" => NormalDelete.deleteByDfa (app, count, Cursor.nextWord, time) | #"W" => NormalDelete.deleteByDfa (app, count, Cursor.nextWORD, time) @@ -352,7 +352,7 @@ struct * but 'dj' or 'dk' delete whole lines * so their implementation differs from * other cursor motions *) - | #"j" => NormalYankDelete.deleteLine (app, count + 1, time) + | #"j" => NormalYankDelete.deleteLineDown (app, count, time) | #"k" => NormalYankDelete.deleteLineBack (app, count, time) | #"w" => NormalYankDelete.deleteByDfa (app, count, Cursor.nextWord, time) | #"W" => NormalYankDelete.deleteByDfa (app, count, Cursor.nextWORD, time)