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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user