fix bug found by unit test: when deleting leftwards, we should never delete beyond the end of the line

This commit is contained in:
2025-09-20 18:04:59 +01:00
parent a0add68e92
commit 2758b864bc
2 changed files with 16 additions and 2 deletions

View File

@@ -213,7 +213,7 @@ struct
fun deleteByDfa (app: app_type, count, fMove, time) =
let
val {buffer, cursorIdx, searchString, ...} = app
val {buffer, cursorIdx, ...} = app
val buffer = LineGap.goToIdx (cursorIdx, buffer)
val otherIdx = fMove (buffer, cursorIdx, count)
@@ -225,6 +225,20 @@ struct
deleteAndFinish (app, low, length, buffer, time)
end
fun deleteCharsLeft (app: app_type, count, time) =
let
val {buffer, cursorIdx, ...} = app
val buffer = LineGap.goToIdx (cursorIdx, buffer)
val startOfLine = Cursor.vi0 (buffer, cursorIdx)
val low = Cursor.viH (buffer, cursorIdx, count)
val low = if low < startOfLine then startOfLine else low
val length = cursorIdx - low
in
deleteAndFinish (app, low, length, buffer, time)
end
fun deleteToEndOfPrevWord (app: app_type, count, time) =
let
val {buffer, cursorIdx, searchString, ...} = app