summaryrefslogtreecommitdiff
path: root/state.lua
diff options
context:
space:
mode:
Diffstat (limited to 'state.lua')
-rw-r--r--state.lua14
1 files changed, 9 insertions, 5 deletions
diff --git a/state.lua b/state.lua
index da26a9a..a88fe41 100644
--- a/state.lua
+++ b/state.lua
@@ -167,7 +167,7 @@ function menu_mt:update_search_matches()
local options = {}
for _, v in ipairs(self.search_options) do
- local matches = {}
+ local matches
local name = v.name
if not case_sensitive then
@@ -180,13 +180,17 @@ function menu_mt:update_search_matches()
if not i then
break
end
+ matches = matches or {}
matches[#matches+1] = {start = i, stop = j}
end
- if #matches > 0 then
- local t = util.copy_table(v)
- t.matches = matches
- options[#options+1] = t
+ if matches then
+ -- search options may contain dynamic data that is
+ -- updated on redraw. using a proxy table instead of
+ -- copying prevents potential updates on every change
+ -- of search text.
+ options[#options+1] = setmetatable(
+ {matches = matches}, {__index = v})
end
end