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) = fun deletePair (app: app_type, time) =
let let
val {cursorIdx, buffer, dfa, ...} = app val {cursorIdx, buffer, dfa, ...} = app
val otherIdx = Cursor.matchPair (buffer, cursorIdx) val buffer = LineGap.goToIdx (cursorIdx, buffer)
val otherIdx = Cursor.nextPairChr (buffer, cursorIdx)
in 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 NormalFinish.clearMode app
else else
let let
@@ -1164,4 +1172,5 @@ struct
(app, buffer, low, searchList, initialMsg, time) (app, buffer, low, searchList, initialMsg, time)
end end
end end
end
end end

View File

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