kazhala/close-buffers.nvim

Incorrect behavior when closing last buffer when NvimTree is open

xyven1 opened this issue · 3 comments

When closing the last buffer with NvimTree open and preserve_window_layout on, close-buffers will also close the NvimTree buffer (but correctly preserve the windows), even though I have NvimTree in the ignore list.
This bug occurs when running :BDelete with this, all, etc (anything with preserve_window_layout on and that removes the last buffer)
Before running :BDelete this
image

After:
image

Correct behavior:
image

I managed to partially fix the issue by filtering what windows to affect when preserving windows (line 53 buffers.lua):

local all_windows = vim.tbl_filter(function(win) 
  return api.nvim_buf_get_option(api.nvim_win_get_buf(win), 'buftype') ~= 'nofile'
end, api.nvim_list_wins())

Still some wonky behavior with NvimTree though

towry commented

Even worst if has split window:

截屏2022-06-10 15 44 57


Considering use another plugin, which works pretty well with nvim-tree.

https://github.com/ojroques/nvim-bufdel

Also set hijack_unnamed_buffer_when_opening = true in nvim-tree will reuse nameless buffer.

Thanks for the tip. I will look into the other plugin, and I will definitely add the hijack option to nvim-tree