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.
This commit is contained in:
zeertzjq 2024-11-03 11:28:31 +08:00 committed by GitHub
parent 3075c69ff0
commit 99acc9de55
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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)