code outline of a function to extend an existing match in search-list.sml.
This commit is contained in:
@@ -176,6 +176,44 @@ struct
|
||||
(idx + 1, buffer, searchList, dfa, newState, startPos, prevFinalPos)
|
||||
end
|
||||
|
||||
fun tryExtendingPrevMatch
|
||||
(idx, buffer, searchList, dfa, prevMatchFinish, finalPos, curState) =
|
||||
if idx = #textLength buffer then
|
||||
if finalPos = prevMatchFinish then
|
||||
(* call insertUntilMatch *)
|
||||
0
|
||||
else
|
||||
(* update searchList, replacing prevMatchFinish with finalPos,
|
||||
* and then call insertUntilMatch with new searchList *)
|
||||
0
|
||||
else
|
||||
let
|
||||
val buffer = LineGap.goToIdx (idx, buffer)
|
||||
val chr = LineGap.sub (idx, buffer)
|
||||
val newState = Dfa.nextState (dfa, curState, chr)
|
||||
val finalPos = if Dfa.isFinal (dfa, newState) then idx else finalPos
|
||||
in
|
||||
if Dfa.isDead newState then
|
||||
if finalPos = prevMatchFinish then
|
||||
(* call insertUntilMatch *)
|
||||
0
|
||||
else
|
||||
(* update searchList, replacing prevMatchFinish with finalPos,
|
||||
* and then call insertUntilMatch with new searchList *)
|
||||
0
|
||||
else
|
||||
(* continue *)
|
||||
tryExtendingPrevMatch
|
||||
( idx + 1
|
||||
, buffer
|
||||
, searchList
|
||||
, dfa
|
||||
, prevMatchFinish
|
||||
, finalPos
|
||||
, newState
|
||||
)
|
||||
end
|
||||
|
||||
fun deleteBufferAndSearchList (start, length, buffer, searchList, dfa) =
|
||||
let
|
||||
val buffer = LineGap.delete (start, length, buffer)
|
||||
|
||||
3
todo.md
3
todo.md
@@ -1,5 +1,8 @@
|
||||
# To-do list
|
||||
- Make sure that all delete function in make-normal-delete.sml also delete from searchList
|
||||
- Handle edge cases regarding deletion from searchList.
|
||||
- Edge case 1: deletion causes a match to be extended
|
||||
- Any other edge cases possible?
|
||||
- Add normal-delete tests for each motion, checking that searchList is as expected
|
||||
- Add tests for other yank motoins
|
||||
- Tests should be based on existing tests for delete-motions, and in the same order.
|
||||
|
||||
Reference in New Issue
Block a user