VidocqH / lsp-lens.nvim

Neovim plugin for displaying references and difinition infos upon functions like JB's IDEA.
MIT License
252 stars 15 forks source link

Fix already closing handler by remove unnecessary timer stop in do_request function #11

Closed xiantang closed 1 year ago

xiantang commented 1 year ago

image_2023-03-12_13-56-36

I have already close handler error when using lsp-lens.nvim, I found code stop timer first and then close. I assumed that the stop function closes the timer and when we stop the timer, it gets stopped again.

So I tried to remove the stop code and it worked.

And I also found the latest document about it: https://neovim.io/doc/user/lua.html#lua-loop this example shows that we don't need timer:stop() anymore

-- Create a timer handle (implementation detail: uv_timer_t).
local timer = vim.loop.new_timer()
local i = 0
-- Waits 1000ms, then repeats every 750ms until timer:close().
timer:start(1000, 750, function()
  print('timer invoked! i='..tostring(i))
  if i > 4 then
    timer:close()  -- Always close handles to avoid leaks.
  end
  i = i + 1
end)
print('sleeping');
VidocqH commented 1 year ago

Thanks!!