fix bugs related to deleting ('dge' and 'dgE' motions should also delete the letter which the cursor is currently at, and now they do)

This commit is contained in:
2025-09-06 00:02:37 +01:00
parent 76e14ea491
commit b9332bcd94
3 changed files with 29 additions and 2 deletions

View File

@@ -152,6 +152,30 @@ struct
deleteAndFinish (app, low, length, buffer, time) deleteAndFinish (app, low, length, buffer, time)
end end
fun deleteToEndOfPrevWord (app: app_type, count, time) =
let
val {buffer, cursorIdx, searchString, ...} = app
val buffer = LineGap.goToIdx (cursorIdx, buffer)
val low = Cursor.endOfPrevWord (buffer, cursorIdx, count)
val length = (cursorIdx + 1) - low
in
deleteAndFinish (app, low, length, buffer, time)
end
fun deleteToEndOfPrevWORD (app: app_type, count, time) =
let
val {buffer, cursorIdx, searchString, ...} = app
val buffer = LineGap.goToIdx (cursorIdx, buffer)
val low = Cursor.endOfPrevWORD (buffer, cursorIdx, count)
val length = (cursorIdx + 1) - low
in
deleteAndFinish (app, low, length, buffer, time)
end
fun deleteToEndOfLine (app: app_type, time) = fun deleteToEndOfLine (app: app_type, time) =
let let
val {buffer, cursorIdx, ...} = app val {buffer, cursorIdx, ...} = app
@@ -291,6 +315,8 @@ struct
let let
val {cursorIdx, buffer, windowWidth, windowHeight, searchString, ...} = val {cursorIdx, buffer, windowWidth, windowHeight, searchString, ...} =
app app
val buffer = LineGap.goToIdx (cursorIdx, buffer)
val cursorIdx = Cursor.viDlrForDelete (buffer, cursorIdx, 1)
val buffer = LineGap.delete (0, cursorIdx, buffer) val buffer = LineGap.delete (0, cursorIdx, buffer)

View File

@@ -172,8 +172,8 @@ struct
fun parseDeleteGo (app, count, chrCmd, time) = fun parseDeleteGo (app, count, chrCmd, time) =
case chrCmd of case chrCmd of
#"e" => NormalDelete.deleteByDfa (app, count, Cursor.endOfPrevWord, time) #"e" => NormalDelete.deleteToEndOfPrevWord (app, count, time)
| #"E" => NormalDelete.deleteByDfa (app, count, Cursor.endOfPrevWORD, time) | #"E" => NormalDelete.deleteToEndOfPrevWORD (app, count, time)
| #"g" => NormalDelete.deleteToStart (app, time) | #"g" => NormalDelete.deleteToStart (app, time)
| _ => NormalFinish.clearMode app | _ => NormalFinish.clearMode app

View File

@@ -246,6 +246,7 @@ struct
fun yankToStart (app: app_type) = fun yankToStart (app: app_type) =
let let
val {cursorIdx, buffer, ...} = app val {cursorIdx, buffer, ...} = app
val buffer = LineGap.goToIdx (cursorIdx, buffer)
val high = Cursor.viDlrForDelete (buffer, cursorIdx, 1) val high = Cursor.viDlrForDelete (buffer, cursorIdx, 1)
val buffer = LineGap.goToIdx (high, buffer) val buffer = LineGap.goToIdx (high, buffer)