From 8d4990b8fd4808b9b2d37ebfe10b814fc51267ee Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 29 Jan 2023 00:55:49 -0800 Subject: [PATCH] don't autorefresh the enableable tools list it just takes too long (>1s) to refresh every time. manual refresh with script_manager.reload() is still available for devs who need it --- library/lua/script-manager.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/library/lua/script-manager.lua b/library/lua/script-manager.lua index c1b8c80d5..cc5dd9fe3 100644 --- a/library/lua/script-manager.lua +++ b/library/lua/script-manager.lua @@ -24,7 +24,7 @@ function foreach_module_script(cb) end end -local enabled_map = {} +local enabled_map = nil local function process_script(env_name, env) local global_name = 'isEnabled' @@ -44,10 +44,14 @@ function reload() foreach_module_script(process_script) end +local function ensure_loaded() + if not enabled_map then + reload() + end +end + function list() - -- call reload every time we list to make sure we get scripts that have - -- just been added - reload() + ensure_loaded() for name,fn in pairs(enabled_map) do print(('%21s %-3s'):format(name..':', fn() and 'on' or 'off')) end