Closed IgorGee closed 4 years ago
Well, :Fern -drawer
-keep
option, closing the last buffer via :q
close Vim
-keep
option, closing the last buffer via :q
does NOT close Vim by adding a blank buffer
Thus what you explained sounds an expected behavior of -keep
option.
Note that I don't use :bd
thus I had not defined behavior of that with/without -keep
option.
Please clarify the Vim's native behavior of :bd
and expected behavior of :bd
on the drawer buffer with/without -keep
option.
In this case, I assumed that the drawer style fern buffer is like a sub-component of the last buffer thus closing the last buffer should close Vim itself
I really don't have any experience in vimscript, but I believe this is the relevant section of code: https://github.com/lambdalisue/fern.vim/blob/master/autoload/fern/internal/drawer.vim#L75
You're checking if it's the last window, not the last buffer. As you can see in my gif above, I had two more buffers that I was interested in editing, which is why I only closed the current buffer with bd
.
Please clarify the Vim's native behavior of :bd
Here is an animation of how I use vim, with buffers. I'm going to leave my customizations present to make it clear which buffer I'm on. But if you'd like to see a demo of what it looks like with a minimal vim configuration, let me know.
Note that when I close a buffer :bd
, it goes to another buffer (I believe it's MRU)
and expected behavior of :bd on the drawer buffer with/without -keep option.
I'm going to explain my expectation without -keep
:
Like you saw in my original post, when I used :bn
, fern stayed open and simply switched to the next buffer. I have the same expectation with :bd
, except it would close the buffer I was on. Right now, fern acts in the same way as if I pressed :q
on my last window.
In my googling for this issue, I actually found a plugin that solves this problem more generically: https://github.com/qpkorr/vim-bufkill
Here's the behavior I was after (note the use of :BD
):
I'm not sure if this feature is within the scope of fern
. I'm probably going to keep vim-bufkill
.
If you feel this is out of scope, please close this issue.
It seems :bd
on the last window on the last tab page switch buffer to the opened one or opens a new one.
I'm still not clear what are the expected behavior for :bd
on each situations...
let g:fern#disable_drawer_auto_quit = 1
:Fern -drawer -stay . +--+---------------+
|FE|# |
|RN| |
+--+---------------+
:q +------------------+
|FE |
|RN |
+------------------+
:Fern -drawer -stay . +--+---------------+
|FE|# |
|RN| |
+--+---------------+
:bd ?
let g:fern#disable_drawer_auto_quit = 0
:Fern -drawer -stay . +--+---------------+
|FE|# |
|RN| |
+--+---------------+
:q Quit vim
:Fern -drawer -keep -stay . +--+---------------+
|FE|# |
|RN| |
+--+---------------+
:q +------------------+
|FE|# (new buf) |
|RN| |
+------------------+
:Fern -drawer -stay . +--+---------------+
|FE|# |
|RN| |
+--+---------------+
:bd ?
:Fern -drawer -keep -stay . +--+---------------+
|FE|# |
|RN| |
+--+---------------+
:bd ?
I'm still not clear what are the expected behavior for
:bd
on each situations...let g:fern#disable_drawer_auto_quit = 1 :Fern -drawer -stay . +--+---------------+ |FE|# | |RN| | +--+---------------+ :q +------------------+ |FE | |RN | +------------------+ :Fern -drawer -stay . +--+---------------+ |FE|# | |RN| | +--+---------------+ :bd ?
If there is another buffer, switch to it.
Else,
+------------------+
|FE|# (new buf) |
|RN| |
+------------------+
let g:fern#disable_drawer_auto_quit = 0 :Fern -drawer -stay . +--+---------------+ |FE|# | |RN| | +--+---------------+ :q Quit vim :Fern -drawer -keep -stay . +--+---------------+ |FE|# | |RN| | +--+---------------+ :q +------------------+ |FE|# (new buf) | |RN| | +------------------+ :Fern -drawer -stay . +--+---------------+ |FE|# | |RN| | +--+---------------+ :bd ?
If there is another buffer, switch to it.
Else,
+------------------+
|FE|# (new buf) |
|RN| |
+------------------+
:Fern -drawer -keep -stay . +--+---------------+ |FE|# | |RN| | +--+---------------+ :bd ?
If there is another buffer, switch to it.
Else,
+------------------+
|FE|# (new buf) |
|RN| |
+------------------+
I don't think g:fern#disable_drawer_auto_quit
or -keep
should change the standard behavior of :bd
. Those options seem to be for :q
.
So all the outcomes of :bd
are the same and consistent.
Sorry for the late. I'm a bit busy recently @IgorGee
This is the native behavior of :bd
thus the current behavior of :bd
when g:fern#disable_drawer_auto_quit = 1
(current behavior is the same as :q
on the above scheme, close the buffer and only fern buffer remains in 100% width) is correct right?
I'd like to clear above to focus on the behavior of :bd
on g:fern#disable_drawer_auto_quit = 0
No problem, I understand the hardships of maintaining such a large and popular open source project. I appreciate it :)
This is the native behavior of :bd thus the current behavior of :bd when g:fern#disable_drawer_auto_quit = 1 (current behavior is the same as :q on the above scheme, close the buffer and only fern buffer remains in 100% width) is correct right?
Yes, this feels like the correct/expected behavior.
OK then there are one issue and one feature request
The "auto quit" feature for :q
affects the behavior of :bd
. It should NOT affect it and :bd
should works like below independent from the value of g:fern#disable_drawer_auto_quit
:Fern -drawer . +--+---------------+
|FE|# |
|RN| |
+--+---------------+
:bd +------------------+
|FE |
|RN |
+------------------+
It would be nice if :bd
works like there is no fern drawer like
" When there is only TWO buffers (fern + buffer A)
:Fern -drawer . +--+---------------+
|FE|# A |
|RN| |
+--+---------------+
:bd +------------------+
|FE|# (new buf) |
|RN| |
+------------------+
" When there is more than TWO buffers (fern + buffer A, B, ....)
:Fern -drawer . +--+---------------+
|FE|# B |
|RN| |
+--+---------------+
:bd +------------------+
|FE|# A |
|RN| |
+------------------+
right? @IgorGee
I'll first fix the issue then try the feature request (not sure possible or not)
Correct.
I understand if you cannot implement the new feature since it doesn't seem like fern's responsibility.
Closed due to #213, #214
Here is a gif of the issue:
The
-keep
option is very inconvenient because it adds a blank buffer, that I have to close.When I close a buffer via
:bd
, I'm expecting to go to the next buffer, preferably withfern
still open. When I quit via:q
, assuming there are no other windows aside fromfern
, I'm expecting vim to close.