From 0255b127a755ef631cc53ea4c2fd017988383b71 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Thu, 25 Sep 2025 08:34:23 +0100 Subject: [PATCH] fix minor bug in make-dfa-loop.sml: when folding backwards using an if-statement, make sure we start folding from the leftStrings if the cursorIdx < 0 --- fcore/cursor-dfa/make-dfa-loop.sml | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/fcore/cursor-dfa/make-dfa-loop.sml b/fcore/cursor-dfa/make-dfa-loop.sml index dfe2b49..0a7a9d1 100644 --- a/fcore/cursor-dfa/make-dfa-loop.sml +++ b/fcore/cursor-dfa/make-dfa-loop.sml @@ -224,9 +224,23 @@ struct val strIdx = cursorIdx - bufferIdx in if strIdx < String.size strHd then - (* strIdx is in this string *) - Fn.fStart - (strIdx, strHd, lnHd, cursorIdx, leftStrings, leftLines, env) + (* strIdx is either in this string or in leftStrings *) + if strIdx < 0 then + case (leftStrings, leftLines) of + (lshd :: lstl, llhd :: lltl) => + Fn.fStart + ( String.size lshd - 1 + , lshd + , llhd + , cursorIdx + , lstl + , lltl + , env + ) + | (_, _) => 0 + else + Fn.fStart + (strIdx, strHd, lnHd, cursorIdx, leftStrings, leftLines, env) else (* strIdx must be in the strTl *) (case (strTl, lnTl) of