bug fix when yanking or deleting inside a word (we should not clip 'high' value, and we should search for end of word strictly); this handles cases like when we only have one character in the buffer, or an empty buffer

This commit is contained in:
2025-09-06 01:12:59 +01:00
parent b9332bcd94
commit 73ec4e7578
5 changed files with 249 additions and 730 deletions

View File

@@ -257,4 +257,23 @@ struct
in
NormalModeWith.modeAndBuffer (app, buffer, mode, [DRAW msg])
end
fun yankInsideWord (app: app_type) =
let
val {buffer, cursorIdx, searchString, ...} = app
val buffer = LineGap.goToIdx (cursorIdx, buffer)
val low = Cursor.prevWordStrict (buffer, cursorIdx, 1)
val high = Cursor.endOfWordStrict (buffer, cursorIdx, 1)
val high = high + 1
val buffer = LineGap.goToIdx (high, buffer)
val length = high - low
val str = LineGap.substring (low, length, buffer)
val msg = YANK str
val mode = NORMAL_MODE ""
in
if str = "\n" then app
else NormalModeWith.modeAndBuffer (app, buffer, mode, [DRAW msg])
end
end