From d9380bcb64979c4c0a4526e1c70f84f48ded9202 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Sat, 27 Sep 2025 12:40:28 +0100 Subject: [PATCH] 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. --- fcore/search-list.sml | 6 +++--- test/regression.sml | 4 ---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/fcore/search-list.sml b/fcore/search-list.sml index f28e960..a9e8bfe 100644 --- a/fcore/search-list.sml +++ b/fcore/search-list.sml @@ -96,9 +96,7 @@ struct fun backtrackRange (pos, hd, absIdx, tl, acc, searchPos, searchString, finish, prevTl) = - if searchPos <= 1 then - loopRange (pos, hd, absIdx, tl, acc, 0, searchString, finish, prevTl) - else if pos < 0 then + if pos < 0 then case prevTl of prevHd :: prevTl => let @@ -119,6 +117,8 @@ struct | [] => (* Should never be called *) raise Fail "SearchList.backtrackRange error: line 120\n" + else if searchPos <= 1 then + loopRange (pos, hd, absIdx, tl, acc, 0, searchString, finish, prevTl) else backtrackRange ( pos - 1 diff --git a/test/regression.sml b/test/regression.sml index 0eb0dfe..4be552e 100644 --- a/test/regression.sml +++ b/test/regression.sml @@ -64,10 +64,6 @@ struct (* move and then delete twice *) val app = TestUtils.updateMany (app, "edede") - - val s = LineGap.toString (#buffer app) - val s = String.toCString s ^ "\n" - val () = print s in Expect.isTrue true end)