Skip to content

Commit

Permalink
feat: improve cleanup logic
Browse files Browse the repository at this point in the history
  • Loading branch information
vyfor committed Dec 22, 2024
1 parent bf27f76 commit 1b9be0c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lua/cord.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function M.initialize()
M.producer = Producer.new(M.client)
M.handler = Handler.new(M.client)
M.handler:register('initialize', function(pid)
vim.g.cord_pid = pid
local executable = file_manager.get_executable_name()
local target_path = file_manager.get_target_path(executable)
uv.fs_stat(target_path, function(err)
Expand Down Expand Up @@ -76,8 +77,17 @@ function M.setup(opts)
end

function M.cleanup()
if M.manager then M.manager.idle_timer:close() end
if M.client then M.client:close() end
if M.manager then
M.manager.clear_autocmds()
M.manager.idle_timer:close()
M.manager = nil
end
if M.client then
M.client:close()
M.client = nil
end
M.producer = nil
M.handler = nil
end

return M

0 comments on commit 1b9be0c

Please sign in to comment.