fix(view): do not close window when NvimTree buffer is replaced #1391
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With
actions.open_file
enabled, when an NvimTree buffer is changed to some other buffer, the window in which that buffer swap occurs is closed.Since the
quit_on_open
function runs onNvimTree
BufWipeout
, there should not be a need to close the window that holds that buffer. Looking at the code, it seemed sensible to not to call_prevent_buffer_override
ifquit_on_open
is enabled, since at best it's a no-op, and at worst it will accidentally modify the window layout.This issue could be reproduced by:
:e firstfile.txt
:vs
:lua require("nvim-tree").open_replacing_current_buffer()
:e somefile.txt
The window containing the buffer opened in the first step would be closed. There would be only a single window with
somefile.txt
on that tab page.Peek.2022-07-03.12-44-failed.mp4
With this fix, that window is retained and the tab now contains
firstfile.txt
in the left window andsomefile.txt
in the rightwindow.
Peek.2022-07-03.12-44.mp4