reimplement 'yt<char>' motion to use 'Cursor.toNextChr'

This commit is contained in:
2025-10-18 19:55:53 +01:00
parent 9f53c5549a
commit 60ec24453f
2 changed files with 22 additions and 1 deletions

View File

@@ -529,7 +529,7 @@ struct
parseYankTerminal (str, count, app, chrCmd, time)
else
case String.sub (str, strPos + 1) of
#"t" => NormalYank.yankToChr (app, 1, Cursor.tillNextChr, op+, chrCmd)
#"t" => NormalYank.yankTillNextChr (app, count, chrCmd)
| #"T" => NormalYank.yankToChr (app, 1, Cursor.tillPrevChr, op-, chrCmd)
| #"f" => NormalYank.yankToNextChr (app, count, chrCmd)
| #"F" =>

View File

@@ -251,6 +251,27 @@ struct
end
end
fun yankTillNextChr (app: app_type, count, chr) =
let
val {buffer, cursorIdx, ...} = app
val buffer = LineGap.goToIdx (cursorIdx, buffer)
val newCursorIdx =
Cursor.toNextChr (buffer, cursorIdx, {findChr = chr, count = count})
in
if newCursorIdx = ~1 then
NormalFinish.clearMode app
else
let
val length = newCursorIdx - cursorIdx
val buffer = LineGap.goToIdx (newCursorIdx, buffer)
val str = LineGap.substring (cursorIdx, length, buffer)
val msg = YANK str
val mode = NORMAL_MODE ""
in
NormalModeWith.modeAndBuffer (app, buffer, mode, [DRAW msg])
end
end
fun yankToChr (app: app_type, count, fMove, fInc, chr) =
helpYankToChr
( app