reimplement d% motion so that it first searches for the next occurrence of a pair-character before trying to match it. (Next: add tests for d% motion.)

This commit is contained in:
2026-01-01 07:05:06 +00:00
parent 44dbe1ffb0
commit 54ef305314
2 changed files with 35 additions and 28 deletions

View File

@@ -1132,9 +1132,17 @@ struct
fun deletePair (app: app_type, time) =
let
val {cursorIdx, buffer, dfa, ...} = app
val otherIdx = Cursor.matchPair (buffer, cursorIdx)
val buffer = LineGap.goToIdx (cursorIdx, buffer)
val otherIdx = Cursor.nextPairChr (buffer, cursorIdx)
in
if otherIdx = cursorIdx then
if otherIdx = ~1 then
NormalFinish.clearMode app
else
let
val buffer = LineGap.goToIdx (otherIdx, buffer)
val otherIdx = Cursor.matchPair (buffer, otherIdx)
in
if otherIdx = ~1 then
NormalFinish.clearMode app
else
let
@@ -1165,3 +1173,4 @@ struct
end
end
end
end

View File

@@ -1,9 +1,7 @@
# To-do list
- Add tests for:
- Reimplement `d%` motion.
- It should both search for the next character in any pair, the same way in Vim
- Add tests for reimplemented movements and motions
- `d%` motion
- Reimplement `di<symbol>` and `da<symbol>`
- They should search for the next char in the specific pair, the same way in Vim
- Add tests for both