From 79d232df7a296ff19ceec6e81b6696bbc30b4566 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Tue, 23 Sep 2025 07:36:51 +0100 Subject: [PATCH] amend very minor bug: when looping through DFA and hitting a 'final state', we let the next chr afterwards handle the start state, but we want the current char to handle the start state instead, as this matches vim's behaviour --- fcore/cursor-dfa/make-dfa-loop.sml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/fcore/cursor-dfa/make-dfa-loop.sml b/fcore/cursor-dfa/make-dfa-loop.sml index 50712a5..dfe2b49 100644 --- a/fcore/cursor-dfa/make-dfa-loop.sml +++ b/fcore/cursor-dfa/make-dfa-loop.sml @@ -157,8 +157,10 @@ struct if counter - 1 = 0 then Fn.finish absIdx else - (* new loop, so reset to start state and proceed *) - foldNext (idx + 1, absIdx + 1, str, tl, Fn.startState, counter - 1) + (* new loop, so reset start state and proceed *) + let val newState = nextState (Fn.startState, chr) + in foldNext (idx + 1, absIdx + 1, str, tl, newState, counter - 1) + end else foldNext (idx + 1, absIdx + 1, str, tl, newState, counter) end @@ -190,7 +192,9 @@ struct if counter - 1 = 0 then Fn.finish absIdx else - foldPrev (idx - 1, absIdx - 1, str, tl, Fn.startState, counter - 1) + let val newState = nextState (Fn.startState, chr) + in foldPrev (idx - 1, absIdx - 1, str, tl, newState, counter - 1) + end else foldPrev (idx - 1, absIdx - 1, str, tl, newState, counter) end