diff --git a/fcore/cursor-dfa/make-dfa-loop.sml b/fcore/cursor-dfa/make-dfa-loop.sml index f102d56..628878c 100644 --- a/fcore/cursor-dfa/make-dfa-loop.sml +++ b/fcore/cursor-dfa/make-dfa-loop.sml @@ -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) diff --git a/fcore/move.sml b/fcore/move.sml index 359a902..c70d9a8 100644 --- a/fcore/move.sml +++ b/fcore/move.sml @@ -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)