mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 03:05:11 -07:00
fix(treesitter): keep treeview open if source window is still open #31198
Problem: When there is a tree view opened by :InspectTree and the source buffer is open in multiple windows, closing one of the source windows will lead to the tree view being closed as well. Regression by #31181. Solution: Check how many source windows are open when trying to quit one. If there are more than one, keep the tree view(s) open. If the only source window is closed, also close the tree view(s). fix #31196
This commit is contained in:
parent
54c85bcb6d
commit
6ef80eb42c
@ -530,12 +530,19 @@ function M.inspect_tree(opts)
|
||||
api.nvim_create_autocmd({ 'BufHidden', 'BufUnload', 'QuitPre' }, {
|
||||
group = group,
|
||||
buffer = buf,
|
||||
once = true,
|
||||
callback = function()
|
||||
-- don't close inpector window if source buffer
|
||||
-- has more than one open window
|
||||
if #vim.fn.win_findbuf(buf) > 1 then
|
||||
return
|
||||
end
|
||||
|
||||
-- close all tree windows
|
||||
for _, window in pairs(vim.fn.win_findbuf(b)) do
|
||||
close_win(window)
|
||||
end
|
||||
|
||||
return true
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user