diff --git a/fcore/search-list/search-list.sml b/fcore/search-list/search-list.sml index 42f4c1c..43cf521 100644 --- a/fcore/search-list/search-list.sml +++ b/fcore/search-list/search-list.sml @@ -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) diff --git a/todo.md b/todo.md index cc9773e..eb3ca42 100644 --- a/todo.md +++ b/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.