pass regression test by modifying 'SearchList.backtrackRange' function. The modification that worked was swapping two if-statements around: first we check if the string position is 0 (and loop to check the previous string if so); in the else case, we check if the searchPos <= 1 (which signals for us to exit backtracking). Swapping the order of the if-statements means that, when we exit the loop, we always exit with string that is at this position.

This commit is contained in:
2025-09-27 12:40:28 +01:00
parent 39db9c652e
commit d9380bcb64
2 changed files with 3 additions and 7 deletions

View File

@@ -96,9 +96,7 @@ struct
fun backtrackRange fun backtrackRange
(pos, hd, absIdx, tl, acc, searchPos, searchString, finish, prevTl) = (pos, hd, absIdx, tl, acc, searchPos, searchString, finish, prevTl) =
if searchPos <= 1 then if pos < 0 then
loopRange (pos, hd, absIdx, tl, acc, 0, searchString, finish, prevTl)
else if pos < 0 then
case prevTl of case prevTl of
prevHd :: prevTl => prevHd :: prevTl =>
let let
@@ -119,6 +117,8 @@ struct
| [] => | [] =>
(* Should never be called *) (* Should never be called *)
raise Fail "SearchList.backtrackRange error: line 120\n" raise Fail "SearchList.backtrackRange error: line 120\n"
else if searchPos <= 1 then
loopRange (pos, hd, absIdx, tl, acc, 0, searchString, finish, prevTl)
else else
backtrackRange backtrackRange
( pos - 1 ( pos - 1

View File

@@ -64,10 +64,6 @@ struct
(* move and then delete twice *) (* move and then delete twice *)
val app = TestUtils.updateMany (app, "edede") val app = TestUtils.updateMany (app, "edede")
val s = LineGap.toString (#buffer app)
val s = String.toCString s ^ "\n"
val () = print s
in in
Expect.isTrue true Expect.isTrue true
end) end)