fix bug found by unit test: when deleting leftwards, we should never delete beyond the end of the line
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user