Closed luozhiya closed 1 year ago
The on_detach
callback is not documented (:h LanguageTree:register_cbs()
). You do raise a good point though: if a buffer is deleted the current callbacks are never called, which is a resource leak. From reading the source it seems that on_detach
is too radical, it will fire even if the user executes :edit
. Perhaps a buffer_is_loaded()
check at the beginning will do the trick.
@luozhiya Can you please try the on-detach
branch and report back if the problem still happens?
@HiPhish I've been experiencing this issue as well and tried your branch but it still happens on that branch. It does seem to be fixed on @luozhiya's branch though i.e. #42
@akinsho That branch does not really fix the problem, it just shoves it under the rug. There seems to be a resource leak which :Bdelete
is tripping up on and I want to plug the leak. My last commit did plug a leak, but apparently it was not enough. I will have to install famiu/bufdelete.nvim myself and see what the command does.
I have been able to narrow down the issue. It only happens in the current dev builds, not in 0.9. If I have two windows with a different buffer for each and I execute :bdelete
on one of them I get the error.
I have pinned down the problem: In Neovim 0.10 deleting a buffer emits an on_changedtree
event (see :h LanguageTree:register_cbs()
), but since the buffer is deleted this raises all sort of problems. So the issue is not a resource leak after all. There are two possibilities:
1) This is a bug in Neovim 2) This is a deliberate choice in Neovim
If it is the former I can sit back and wait. If it is the latter I will have to handle this particular edge case like in the PR posted by the OP. I will file an issue in Neovim's repo, then we will see.
The PR has been merged. Please test if the problem has been solved on master
and close this issue if everything is correct now.
Hi,
Describe the bug
When using
Bdelete
to delete a buffer, rainbow will throw an error. In my opinion rainbow needs to register adetach
callback.Thanks.
Neovim Version
NVIM v0.10.0-dev-282+gca5a810c4
Steps to reproduce
minimal
Expected behavior
delete buffer without throw an error.
References
share/nvim/runtime/lua/vim/treesitter/languagetree.lua:877
https://github.com/neovim/neovim/issues/21416