add dfa field to app_type so that we don't rebuild DFA each time we want to execute a search again (like after deleting)

This commit is contained in:
2025-10-08 05:02:15 +01:00
parent 7f68084398
commit fd8385fa81
5 changed files with 27 additions and 3 deletions

View File

@@ -24,6 +24,7 @@ struct
, cursorIdx: int , cursorIdx: int
(* column to start drawing text at for horizontal scrolling. *) (* column to start drawing text at for horizontal scrolling. *)
, visualScrollColumn: int , visualScrollColumn: int
, dfa: int vector vector
(* msgs to send after an update. (* msgs to send after an update.
* The list of messages is reset on each invocation of AppUpdate.update. *) * The list of messages is reset on each invocation of AppUpdate.update. *)
, msgs: MailboxType.t list , msgs: MailboxType.t list
@@ -40,6 +41,7 @@ struct
, startLine = 0 , startLine = 0
, cursorIdx = 0 , cursorIdx = 0
, visualScrollColumn = 0 , visualScrollColumn = 0
, dfa = Vector.fromList []
, msgs = [] , msgs = []
} }
end end

View File

@@ -16,6 +16,7 @@ struct
, searchString , searchString
, startLine , startLine
, cursorIdx , cursorIdx
, dfa
} = app } = app
in in
{ mode = newMode { mode = newMode
@@ -29,6 +30,7 @@ struct
, searchString = searchString , searchString = searchString
, startLine = startLine , startLine = startLine
, cursorIdx = cursorIdx , cursorIdx = cursorIdx
, dfa = dfa
} }
end end
@@ -55,6 +57,7 @@ struct
, searchString , searchString
, startLine , startLine
, cursorIdx , cursorIdx
, dfa
} = app } = app
in in
{ mode = mode { mode = mode
@@ -68,6 +71,7 @@ struct
, searchString = searchString , searchString = searchString
, startLine = startLine , startLine = startLine
, cursorIdx = cursorIdx , cursorIdx = cursorIdx
, dfa = dfa
} }
end end
@@ -95,6 +99,7 @@ struct
, searchString , searchString
, windowWidth , windowWidth
, windowHeight , windowHeight
, dfa
} = app } = app
in in
{ mode = newMode { mode = newMode
@@ -108,6 +113,7 @@ struct
, searchString = searchString , searchString = searchString
, windowWidth = windowWidth , windowWidth = windowWidth
, windowHeight = windowHeight , windowHeight = windowHeight
, dfa = dfa
} }
end end
@@ -125,6 +131,7 @@ struct
, windowHeight , windowHeight
, startLine , startLine
, visualScrollColumn , visualScrollColumn
, dfa
} = app } = app
in in
{ mode = newMode { mode = newMode
@@ -138,6 +145,7 @@ struct
, windowHeight = windowHeight , windowHeight = windowHeight
, startLine = startLine , startLine = startLine
, visualScrollColumn = visualScrollColumn , visualScrollColumn = visualScrollColumn
, dfa = dfa
} }
end end
@@ -155,6 +163,7 @@ struct
, windowHeight , windowHeight
, startLine , startLine
, visualScrollColumn , visualScrollColumn
, dfa
} = app } = app
in in
{ mode = newMode { mode = newMode
@@ -168,10 +177,10 @@ struct
, windowHeight = windowHeight , windowHeight = windowHeight
, startLine = startLine , startLine = startLine
, visualScrollColumn = visualScrollColumn , visualScrollColumn = visualScrollColumn
, dfa = dfa
} }
end end
fun searchList fun searchList
( app: app_type ( app: app_type
, newSearchList , newSearchList
@@ -192,6 +201,7 @@ struct
, windowHeight , windowHeight
, startLine , startLine
, visualScrollColumn , visualScrollColumn
, dfa
} = app } = app
in in
{ searchList = newSearchList { searchList = newSearchList
@@ -205,6 +215,7 @@ struct
, windowHeight = windowHeight , windowHeight = windowHeight
, startLine = startLine , startLine = startLine
, visualScrollColumn = visualScrollColumn , visualScrollColumn = visualScrollColumn
, dfa = dfa
} }
end end
end end

View File

@@ -7,7 +7,7 @@ struct
fun switchToNormalSearchMode (app: app_type) = fun switchToNormalSearchMode (app: app_type) =
NormalSearchFinish.onSearchChanged NormalSearchFinish.onSearchChanged
(app, "", PersistentVector.empty, 0, 0, true, #buffer app) (app, "", PersistentVector.empty, 0, 0, false, #buffer app)
fun getNumLength (pos, str) = fun getNumLength (pos, str) =
if pos = String.size str then if pos = String.size str then

View File

@@ -9,6 +9,7 @@ struct
, newSearchList , newSearchList
, newStartLine , newStartLine
, newMode , newMode
, newDfa
, newMsgs , newMsgs
) = ) =
let let
@@ -19,6 +20,7 @@ struct
, searchList = _ , searchList = _
, startLine = _ , startLine = _
, msgs = _ , msgs = _
, dfa = _
, bufferModifyTime , bufferModifyTime
, windowWidth , windowWidth
, windowHeight , windowHeight
@@ -31,6 +33,7 @@ struct
, searchString = newSearchString , searchString = newSearchString
, searchList = newSearchList , searchList = newSearchList
, startLine = newStartLine , startLine = newStartLine
, dfa = newDfa
, bufferModifyTime = bufferModifyTime , bufferModifyTime = bufferModifyTime
, msgs = newMsgs , msgs = newMsgs
, windowWidth = windowWidth , windowWidth = windowWidth
@@ -55,6 +58,7 @@ struct
, windowHeight , windowHeight
, cursorIdx , cursorIdx
, visualScrollColumn , visualScrollColumn
, dfa
} = app } = app
in in
{ mode = newMode { mode = newMode
@@ -68,6 +72,7 @@ struct
, windowHeight = windowHeight , windowHeight = windowHeight
, cursorIdx = cursorIdx , cursorIdx = cursorIdx
, visualScrollColumn = visualScrollColumn , visualScrollColumn = visualScrollColumn
, dfa = dfa
} }
end end
@@ -85,6 +90,7 @@ struct
, windowHeight , windowHeight
, cursorIdx , cursorIdx
, visualScrollColumn , visualScrollColumn
, dfa
} = app } = app
in in
{ mode = mode { mode = mode
@@ -98,6 +104,7 @@ struct
, windowHeight = windowHeight , windowHeight = windowHeight
, cursorIdx = cursorIdx , cursorIdx = cursorIdx
, visualScrollColumn = visualScrollColumn , visualScrollColumn = visualScrollColumn
, dfa = dfa
} }
end end
@@ -122,6 +129,7 @@ struct
, bufferModifyTime , bufferModifyTime
, cursorIdx , cursorIdx
, visualScrollColumn , visualScrollColumn
, dfa
} = app } = app
in in
{ mode = newMode { mode = newMode
@@ -135,6 +143,7 @@ struct
, bufferModifyTime = bufferModifyTime , bufferModifyTime = bufferModifyTime
, cursorIdx = cursorIdx , cursorIdx = cursorIdx
, visualScrollColumn = visualScrollColumn , visualScrollColumn = visualScrollColumn
, dfa = dfa
} }
end end
end end

View File

@@ -93,9 +93,11 @@ struct
val msgs = DRAW drawMsg :: initialMsg val msgs = DRAW drawMsg :: initialMsg
val mode = NORMAL_MODE "" val mode = NORMAL_MODE ""
val dfa = raise Fail "todo"
in in
NormalSearchModeWith.returnToNormalMode NormalSearchModeWith.returnToNormalMode
(app, buffer, searchString, tempSearchList, startLine, mode, msgs) (app, buffer, searchString, tempSearchList, startLine, mode, dfa, msgs)
end end
fun backspace fun backspace