From 925aa695b437325d48abc484f2769c6787ebf3f5 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Sat, 31 Jan 2026 02:40:00 -0800 Subject: use menu metatable for saving/restoring search state --- state.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'state.lua') diff --git a/state.lua b/state.lua index 326fa28..3abb892 100644 --- a/state.lua +++ b/state.lua @@ -82,6 +82,21 @@ function mt:insert_favourite_before_next_in_menu(id) self:add_favourite(id) end +function menu_mt:save_checkpoint() + self.checkpoint = { + search_text = self.search_text, + cursor = self.cursor, + view_top = self.view_top, + } +end + +function menu_mt:restore_checkpoint() + local t = self.checkpoint + self:set_search_text(t.search_text) + self.cursor = t.cursor + self.view_top = t.view_top +end + function menu_mt:set_cursor(pos, lines, opts) local pos = math.max(1, math.min(pos, #self.options)) local top = self.view_top -- cgit v1.2.3-70-g09d2