add tests for 'df<char>' motion, uncover bug found by test where new match was not recognised after deletion if match involved last character in buffer, and fix that bug by checking (in fcore/search-list/search-list.sm) if we are at a dead state before we check if we are in the last index of the buffer

This commit is contained in:
2026-04-24 16:29:16 +01:00
parent 504b5309f4
commit fe9048299b
3 changed files with 170 additions and 24 deletions

View File

@@ -131,20 +131,7 @@ struct
fun insertUntilMatch
(idx, buffer, searchList, dfa, curState, startPos, prevFinalPos) =
if idx = #textLength buffer then
if prevFinalPos < 0 then
(buffer, searchList)
else if PersistentVector.isInRange (prevFinalPos, searchList) then
(buffer, searchList)
else
let
val searchList =
PersistentVector.insertMatchKeepingAbsoluteInddices
(startPos, prevFinalPos, searchList)
in
(buffer, searchList)
end
else if Dfa.isDead curState then
if Dfa.isDead curState then
if prevFinalPos = ~1 then
(* no match found: restart search from `startPos + 1` *)
insertUntilMatch
@@ -161,6 +148,19 @@ struct
in
insertUntilMatch (newStart, buffer, searchList, dfa, 0, newStart, ~1)
end
else if idx = #textLength buffer then
if prevFinalPos < 0 then
(buffer, searchList)
else if PersistentVector.isInRange (prevFinalPos, searchList) then
(buffer, searchList)
else
let
val searchList =
PersistentVector.insertMatchKeepingAbsoluteInddices
(startPos, prevFinalPos, searchList)
in
(buffer, searchList)
end
else
let
val buffer = LineGap.goToIdx (idx, buffer)
@@ -176,14 +176,7 @@ struct
fun tryExtendingPrevMatch
(idx, buffer, searchList, dfa, finalPos, curState, start) =
if idx = #textLength buffer then
let
val searchList =
PersistentVector.extendExistingMatch (start, finalPos, searchList)
in
(buffer, searchList)
end
else if Dfa.isDead curState then
if Dfa.isDead curState then
let
val searchList =
PersistentVector.extendExistingMatch (start, finalPos, searchList)
@@ -191,6 +184,13 @@ struct
insertUntilMatch
(finalPos + 1, buffer, searchList, dfa, 0, finalPos + 1, ~1)
end
else if idx = #textLength buffer then
let
val searchList =
PersistentVector.extendExistingMatch (start, finalPos, searchList)
in
(buffer, searchList)
end
else
let
val buffer = LineGap.goToIdx (idx, buffer)