commit 99acc9de559a2ea3b9de2b418dbcae774d1d9a75
parent 3075c69ff02faf396e5efbdcb4a255b0b0309649
Author: zeertzjq <zeertzjq@outlook.com>
Date: Sun, 3 Nov 2024 11:28:31 +0800
fix(treesitter): close InspectTree/EditQuery window on BufUnload (#31036)
Problem: The window opened :InspectTree or :EditQuery isn't closed when
the source buffer is unloaded, even though it is closed when
the buffer is hidden.
Solution: Also close the window on BufUnload.
Diffstat:
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/runtime/lua/vim/treesitter/dev.lua b/runtime/lua/vim/treesitter/dev.lua
@@ -527,7 +527,7 @@ function M.inspect_tree(opts)
end,
})
- api.nvim_create_autocmd('BufHidden', {
+ api.nvim_create_autocmd({ 'BufHidden', 'BufUnload' }, {
group = group,
buffer = buf,
once = true,
@@ -665,10 +665,10 @@ function M.edit_query(lang)
api.nvim_buf_clear_namespace(query_buf, edit_ns, 0, -1)
end,
})
- api.nvim_create_autocmd('BufHidden', {
+ api.nvim_create_autocmd({ 'BufHidden', 'BufUnload' }, {
group = group,
buffer = buf,
- desc = 'Close the editor window when the source buffer is hidden',
+ desc = 'Close the editor window when the source buffer is hidden or unloaded',
once = true,
callback = function()
close_win(query_win)