add some more tests for 'df<char' motion, and fix implementation to pass those tests (if our cursor is at the same position after calling 'fMove', then exit the loop to find the next occurrence of <char>)

This commit is contained in:
2025-10-17 16:19:17 +01:00
parent 09c9a92029
commit b8beeaaa60
3 changed files with 69 additions and 21 deletions

View File

@@ -3531,6 +3531,51 @@ struct
(actualString = expectedString
andalso cursorIdx = expectedCursorIdx)
end)
, test
"deletes from cursor's position to second occurrence of <char> \
\if motion has a count of 2"
(fn _ =>
let
(* arrange *)
val originalString = "hello\nworld\n"
val app = TestUtils.init originalString
val app = AppWith.idx (app, 0)
(* act *)
val {buffer, cursorIdx, ...} = TestUtils.updateMany (app, "2dfo")
(* assert *)
val actualString = LineGap.toString buffer
val expectedString = "rld\n"
val expectedCursorIdx = 0
in
Expect.isTrue
(actualString = expectedString
andalso cursorIdx = expectedCursorIdx)
end)
, test
"deletes from cursor's position to last occurrence of <char> \
\if motion has a count greater than \
\the number of occurences of <char>, after the cursor"
(fn _ =>
let
(* arrange *)
val originalString = "hello\nworld\n"
val app = TestUtils.init originalString
val app = AppWith.idx (app, 0)
(* act *)
val {buffer, cursorIdx, ...} = TestUtils.updateMany (app, "99dfl")
(* assert *)
val actualString = LineGap.toString buffer
val expectedString = "d\n"
val expectedCursorIdx = 0
in
Expect.isTrue
(actualString = expectedString
andalso cursorIdx = expectedCursorIdx)
end)
]
val tests =