From 137cbfee199d3204f80a65d1f000c32864e09e01 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Tue, 2 Dec 2025 17:55:25 +0000 Subject: [PATCH] fix bug when saving search from NORMAL_SEARCH_MODE. Previously, when pressing to save the search, the tempSearchList (which searches against a subset of the buffer's text instead of all of it, to ensure we do not spend too much time was spent while the user was entering the regex/search string) was being saved instead of the newly built searchList (which executes the DFA against all of the text) --- fcore/normal-mode/normal-search-mode.sml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/fcore/normal-mode/normal-search-mode.sml b/fcore/normal-mode/normal-search-mode.sml index 644898a..2d68a75 100644 --- a/fcore/normal-mode/normal-search-mode.sml +++ b/fcore/normal-mode/normal-search-mode.sml @@ -63,9 +63,8 @@ struct (app, buffer, cursorIdx, searchList, [], bufferModifyTime) end - (* save search string and tempSearchList and return to normal mode *) - fun saveSearch - (app: app_type, searchString, tempSearchList, caseSensitive, time) = + (* save search string and searchList and return to normal mode *) + fun saveSearch (app: app_type, searchString, caseSensitive, time) = let val { buffer @@ -82,7 +81,7 @@ struct else CaseInsensitiveDfa.fromString searchString val buffer = LineGap.goToStart buffer - val searchList = SearchList.build (buffer, dfa) + val (buffer, searchList) = SearchList.build (buffer, dfa) (* move LineGap to first line displayed on screen *) val buffer = LineGap.goToLine (startLine, buffer) @@ -96,7 +95,7 @@ struct , buffer , windowWidth , windowHeight - , tempSearchList + , searchList , visualScrollColumn ) val drawMsg = Vector.concat drawMsg @@ -106,7 +105,7 @@ struct val mode = NORMAL_MODE "" in NormalSearchModeWith.returnToNormalMode - (app, buffer, tempSearchList, startLine, mode, dfa, msgs) + (app, buffer, searchList, startLine, mode, dfa, msgs) end fun backspace @@ -233,8 +232,7 @@ struct , caseSensitive ) | KEY_ESC => exitToNormalMode app - | KEY_ENTER => - saveSearch (app, searchString, tempSearchList, caseSensitive, time) + | KEY_ENTER => saveSearch (app, searchString, caseSensitive, time) | ARROW_LEFT => moveLeft ( app