From 77706bcb80c889cb72c1be11c1cd7d32d284039c Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Mon, 28 Oct 2024 09:00:41 +0100 Subject: do not recreate watches after the QUIT event was received --- init.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 03ceda8..01b2ffa 100644 --- a/init.lua +++ b/init.lua @@ -22,6 +22,9 @@ if not os.execute('type inotifywait >/dev/null 2>/dev/null') then return {} end +-- vis is exiting to not recreate watches +local exiting = false + -- We have to keep the handles to our communicate processes otherwise -- vis will terminate them. local watches = {} -- luacheck: ignore watches @@ -41,7 +44,7 @@ local function _add_watch(file, func, mode, cmd_options) if event == 'EXIT' or event == 'SIGNAL' then if event == 'EXIT' then - if mode == 'recreate' then + if mode == 'recreate' and not exiting then -- recreate the watch watches[file] = nil watches[file] = vis:communicate(file, cmd) @@ -72,6 +75,7 @@ M.add_recreate_watch = function(file, func, cmd_options) end vis.events.subscribe(vis.events.QUIT, function() + exiting = true -- Terminate all watches for k, _ in pairs(watches) do watches[k] = nil end end) -- cgit v1.2.3