diff --git a/fcore/normal-mode/make-normal-delete.sml b/fcore/normal-mode/make-normal-delete.sml index b4a2e1f..d7104ac 100644 --- a/fcore/normal-mode/make-normal-delete.sml +++ b/fcore/normal-mode/make-normal-delete.sml @@ -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 diff --git a/fcore/normal-mode/normal-mode.sml b/fcore/normal-mode/normal-mode.sml index 5ef4a25..dd1a4e9 100644 --- a/fcore/normal-mode/normal-mode.sml +++ b/fcore/normal-mode/normal-mode.sml @@ -250,7 +250,7 @@ struct fun parseDeleteTerminal (str, count, app, chrCmd, time) = case chrCmd of (* terminal commands: require no input after *) - #"h" => NormalDelete.deleteByDfa (app, count, Cursor.viH, time) + #"h" => NormalDelete.deleteCharsLeft (app, count, time) | #"l" => NormalDelete.deleteByDfa (app, count, Cursor.viL, time) (* vi's 'j' and 'k' commands move up or down a column * but 'dj' or 'dk' delete whole lines