reimplement 'df' motion as per previous commits, and add a new test for 'df' motion to check that cursor does not land on a 'newline following a non-newline' position, after deleting using 'df<char>'

This commit is contained in:
2025-10-18 14:24:16 +01:00
parent 239aaacfc5
commit 5d00da2cbb
3 changed files with 51 additions and 11 deletions

View File

@@ -648,7 +648,7 @@ struct
fun deleteToFirstNonSpaceChr (app: app_type, time) =
let
val {buffer, cursorIdx, windowWidth, windowHeight, startLine, ...} = app
val {buffer, cursorIdx, ...} = app
(* move LineGap and buffer to start of line *)
val buffer = LineGap.goToIdx (cursorIdx, buffer)
@@ -712,6 +712,31 @@ struct
, time
)
fun deleteToNextChr (app: app_type, count, chr, time) =
let
val {buffer, cursorIdx, ...} = app
val buffer = LineGap.goToIdx (cursorIdx, buffer)
val newCursorIdx =
Cursor.toNextChrNew (buffer, cursorIdx, {findChr = chr, count = count})
in
if newCursorIdx = ~1 then
NormalFinish.clearMode app
else
let
val length = newCursorIdx - cursorIdx + 1
val buffer = LineGap.goToIdx (newCursorIdx, buffer)
val initialMsg = Fn.initMsgs (cursorIdx, length, buffer)
val buffer = LineGap.delete (cursorIdx, length, buffer)
val buffer = LineGap.goToIdx (cursorIdx, buffer)
val cursorIdx =
if Cursor.isOnNewlineAfterChr (buffer, cursorIdx) then cursorIdx - 1
else cursorIdx
in
finishAfterDeletingBuffer (app, cursorIdx, buffer, time, initialMsg)
end
end
fun deleteToStart (app: app_type, time) : AppType.app_type =
let
val {cursorIdx, buffer, windowWidth, windowHeight, dfa, ...} = app