when looping through a DFA in a functor, make sure we return the absolute index to the calling function and not a modified version of the absolute index which has already been clipped

This commit is contained in:
2025-09-16 21:35:48 +01:00
parent 12478f8ac2
commit 96521f358f
2 changed files with 6 additions and 1 deletions

View File

@@ -147,7 +147,7 @@ struct
if idx = String.size str then
case tl of
str :: tl => foldNext (0, absIdx, str, tl, currentState, counter)
| [] => Int.max (absIdx - 2, 0)
| [] => absIdx
else
let
val chr = String.sub (str, idx)

View File

@@ -66,6 +66,11 @@ struct
val {buffer, cursorIdx, searchList, bufferModifyTime, ...} = app
val buffer = LineGap.goToIdx (cursorIdx, buffer)
val cursorIdx = Fn.fMove (buffer, cursorIdx, count)
val textLength = #textLength buffer
val cursorIdx =
if cursorIdx >= textLength - 2 then Int.max (textLength - 2, 0)
else cursorIdx
in
NormalFinish.buildTextAndClear
(app, buffer, cursorIdx, searchList, [], bufferModifyTime)