From 73dfd12f0f7312b17428102116477a2dbca46409 Mon Sep 17 00:00:00 2001 From: ray-x Date: Mon, 10 Jan 2022 01:52:32 +1100 Subject: [PATCH] async handler check status before close --- lua/navigator/gui.lua | 2 +- lua/navigator/reference.lua | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lua/navigator/gui.lua b/lua/navigator/gui.lua index f59a9d4..c9b20dc 100644 --- a/lua/navigator/gui.lua +++ b/lua/navigator/gui.lua @@ -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 diff --git a/lua/navigator/reference.lua b/lua/navigator/reference.lua index 28fbb37..604bc55 100644 --- a/lua/navigator/reference.lua +++ b/lua/navigator/reference.lua @@ -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)