async handler check status before close

neovim_0.6
ray-x 2 years ago
parent db4eb5f155
commit 73dfd12f0f

@ -18,7 +18,7 @@ function M.new_list_view(opts)
if bufnr and vim.api.nvim_buf_is_valid(bufnr) and winnr and vim.api.nvim_win_is_valid(winnr) then
log('list view already present')
return
return active_list_view
end
end
local items = opts.items

@ -90,7 +90,7 @@ local ref_view = function(err, locations, ctx, cfg)
local listview = gui.new_list_view(opts)
if listview == nil then
vim.notify('failed to create preview windows', vim.lsp.log_levels.WARN)
vim.notify('failed to create preview windows', vim.lsp.log_levels.INFO)
return
end
-- trace("update items", listview.ctrl.class)
@ -127,7 +127,9 @@ local ref_hdlr = mk_handler(function(err, locations, ctx, cfg)
trace(err, locations, ctx, cfg)
M.async_hdlr = vim.loop.new_async(vim.schedule_wrap(function()
ref_view(err, locations, ctx, cfg)
M.async_hdlr:close()
if M.async_hdlr:is_active() then
M.async_hdlr:close()
end
end))
M.async_hdlr:send()
end)

Loading…
Cancel
Save