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.

This commit is contained in:
2025-09-25 04:56:25 +01:00
parent 1255238d6c
commit e24230834e
2 changed files with 6 additions and 4 deletions

View File

@@ -343,7 +343,9 @@ struct
end end
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 let
val {buffer, cursorIdx, searchString, ...} = app val {buffer, cursorIdx, searchString, ...} = app
val buffer = LineGap.goToIdx (cursorIdx, buffer) val buffer = LineGap.goToIdx (cursorIdx, buffer)
@@ -356,7 +358,7 @@ struct
LineGap.idxToLineNumber (cursorIdx + 1, buffer) LineGap.idxToLineNumber (cursorIdx + 1, buffer)
else else
LineGap.idxToLineNumber (cursorIdx + 1, buffer) LineGap.idxToLineNumber (cursorIdx + 1, buffer)
val endLine = startLine + count val endLine = startLine + count + 1
val buffer = LineGap.goToLine (endLine, buffer) val buffer = LineGap.goToLine (endLine, buffer)
val endLineIdx = LineGap.lineNumberToIdx (endLine, buffer) val endLineIdx = LineGap.lineNumberToIdx (endLine, buffer)

View File

@@ -256,7 +256,7 @@ struct
* but 'dj' or 'dk' delete whole lines * but 'dj' or 'dk' delete whole lines
* so their implementation differs from * so their implementation differs from
* other cursor motions *) * other cursor motions *)
| #"j" => NormalDelete.deleteLine (app, count + 1, time) | #"j" => NormalDelete.deleteLineDown (app, count, time)
| #"k" => NormalDelete.deleteLineBack (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)
| #"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 * but 'dj' or 'dk' delete whole lines
* so their implementation differs from * so their implementation differs from
* other cursor motions *) * other cursor motions *)
| #"j" => NormalYankDelete.deleteLine (app, count + 1, time) | #"j" => NormalYankDelete.deleteLineDown (app, count, time)
| #"k" => NormalYankDelete.deleteLineBack (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)
| #"W" => NormalYankDelete.deleteByDfa (app, count, Cursor.nextWORD, time) | #"W" => NormalYankDelete.deleteByDfa (app, count, Cursor.nextWORD, time)