close-buffers.nvim icon indicating copy to clipboard operation
close-buffers.nvim copied to clipboard

Incorrect behavior when closing last buffer when NvimTree is open

Open xyven1 opened this issue 2 years ago • 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

xyven1 avatar Apr 25 '22 17:04 xyven1

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

xyven1 avatar Apr 25 '22 18:04 xyven1

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.

towry avatar Jun 10 '22 07:06 towry

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

xyven1 avatar Jun 10 '22 14:06 xyven1