commit cdc33f4cf7963038da5a3a2b6f2e4783fbf8f98a
parent d481b04a6805e70f3f9ae2deeb17cb91cb2cc6a1
Author: lash <dev@holbrook.no>
Date: Tue, 1 Apr 2025 13:58:27 +0100
Hide root cache pop behind config
Diffstat:
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/engine/config.go b/engine/config.go
@@ -26,6 +26,8 @@ type Config struct {
MenuSeparator string
// ResetOnEmptyInput purges cache and restart state execution at root on empty input
ResetOnEmptyInput bool
+ // ResetRoot purges cache for the root node on a engine reset.
+ ResetRoot bool
}
// String implements the string interface.
diff --git a/engine/db.go b/engine/db.go
@@ -500,9 +500,6 @@ func (en *DefaultEngine) Exec(ctx context.Context, input []byte) (bool, error) {
if err != nil {
return v, err
}
-
- cache := en.pe.GetMemory()
- cache.Pop()
}
}
@@ -642,6 +639,9 @@ func (en *DefaultEngine) reset(ctx context.Context) (bool, error) {
}
en.ca.Pop()
}
+ if (en.cfg.ResetRoot) {
+ en.ca.Pop()
+ }
en.st.Restart()
en.st.ResetFlag(state.FLAG_TERMINATE)
en.st.ResetFlag(state.FLAG_DIRTY)