[vim/vim] If you `:bdelete` from a `'winfixbuf'` window, what should happen? (Issue #14328)

24 views
Skip to first unread message

Colin Kennedy

unread,
Mar 29, 2024, 12:23:52 AM3/29/24
to vim/vim, Subscribed

Related: tpope/vim-fugitive#2286

The user notes that if you have a 'winfixbuf', then :bdelete, the current buffer is changed because the previous buffer was deleted. But the window is still 'winfixbuf'-ed so effectively the window points to a different buffer. Is that the behavior that we want?

If not that, here's some alternative ideas:

  1. Fail (with E1513 error) to delete the buffer because a window is 'winfixbuf'-ed to it
  2. Delete the buffer and unset 'winfixbuf' on all windows that point to the buffer
  3. A combination of both (1) and (2)
    • 'winfixbuf' + :bdelete - Fails with E1513 error
    • 'winfixbuf' + :bdelete! - Deletes the buffer and unsets all other windows
  4. Keep the current behavior as it currently is

If not (4) then we'll want to consider changing

(please reply with any commands that I'm missing)

  • :bdelete
  • :bwipeout
  • Possibly :bunload (I don't use this option much)
  • Any other command that deletes / modifies window-buffer relations

And also vimscript functions likely will need to be modified


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/14328@github.com>

Christian Brabandt

unread,
Mar 29, 2024, 4:56:58 AM3/29/24
to vim/vim, Subscribed

Thanks for keeping up with those issues related to 'winfixbuf'. I would think 3 makes the most sense (including bunload and bwipe).


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/14328/2026903597@github.com>

Colin Kennedy

unread,
Mar 29, 2024, 12:34:11 PM3/29/24
to vim/vim, Subscribed

It's my pleasure, I knew we wouldn't get every edge case on the first go-around. I agree, (3) is good, I'll hop on that


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/14328/2027461107@github.com>

7to...@gmail.com

unread,
Mar 29, 2024, 5:01:39 PM3/29/24
to vim_dev
I prefer if :bdelete does not fail in this situation even if there is no <bang> (!). Changing it so that the command fails without <bang> looks like a change that breaks scripts and plugins because :bdelete currently fails only when the buffer has modifications. What's the reason to make it fail when the buffer is not modified?

The whole point of fixing a buffer in a window with winfixbuf is to make sure that no other buffer takes the place (window) of the buffer. But if the buffer is being intentionally deleted by the user then it means it is not needed in that place (or anywhere else) anymore. The situation is similar as with doing :bdelete for a buffer in a tab that has no other window. Vim closes it's window and even removes the whole tab. It does not make the command fail just because there is no <bang>. Is there any reason to handle :bdelete of a winfixbuf-ed buffer differently?

Thinking about possible solutions:
How about just closing the window?
Or is there a way to change winfixbuf option so that it does not only say which buffer is fixed to the window but also says what happens with the window when the buffer becomes deleted?

And by the way:
But then: What happens when the fixed buffer is going to be hidden?

Colin Kennedy

unread,
Mar 30, 2024, 2:51:54 AM3/30/24
to vim/vim, Subscribed

Thinking about :bwipeout, how should that logic work?

If 2 windows, one of them is 'winfixbuf' and the other is not (and the cursor is currently on the 'nowinfixbuf' window), I could imagine :bwipeout having one of two behaviors

  1. Fail to delete any buffer that has at least one 'winfixbuf' window but delete any other buffers
  2. Fail to delete any buffer because at least one 'winfixbuf' window was found
  3. Maybe some other behavior, not sure what that'd be

And then of course :bwipeout! would clear all buffers, even if any of the windows are 'winfixbuf', and the final window that remains gets set to 'nowinfixbuf'.

What do you think @chrisbra?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/14328/2027944667@github.com>

Colin Kennedy

unread,
Apr 11, 2024, 12:32:30 AM4/11/24
to vim/vim, Subscribed

I've got most of the logic working, just need to figure out the best way to handle the bwipeout case. @chrisbra do you have a moment to check out these options? I'm partial to (2) but wanted to get your thoughts. If busy, no worries, I can put up a PR and discuss it there too.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/14328/2048908814@github.com>

Christian Brabandt

unread,
Apr 11, 2024, 11:39:54 AM4/11/24
to vim/vim, Subscribed

so if I understand correctly, you are saying you would prefer the following behaviour:

I have 2 windows open for fileA and fileB. Window1 has fileA and is 'winfixbuf'ed. I am in Window2 with fileB that does not have winfixbuf set and I want to wipe it. You would like to stop the :bwipe just because an unrelated window with an unrelated file has winfixbuf option set? I think this is more annoying than helpful. I think 1) makes more sense, no?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/14328/2049984815@github.com>

Colin Kennedy

unread,
Apr 11, 2024, 11:59:39 AM4/11/24
to vim/vim, Subscribed

Oh my bad, I reread the :help bwipeout. Somehow in my mind I thought :bwipeout deletes all buffers but of course that's actually :%bwipeout. :bwipeout by itself only considers the current buffer (and its window(s))

As you suggested (1) is better after all. And I assume you'd want :bwipeout! to force-delete and then set any leftover window(s) to 'nowinfixbuf' like we've been doing for other commands, right? I can get started on that


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/14328/2050024503@github.com>

Christian Brabandt

unread,
Apr 11, 2024, 12:02:22 PM4/11/24
to vim/vim, Subscribed

yes, correct. Thanks for starting working on that,


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/14328/2050029083@github.com>

Eric Wong

unread,
12:05 PM (9 hours ago) 12:05 PM
to vim/vim, Subscribed
wsdjeg left a comment (vim/vim#14328)

I think :bd should delete the buffer, and current windows's winfixbuf change to false. if there is only one windows, :bd will delete current buffer, and the previous buffer will bu set to current windows. if the prev buf is a normal file. maybe the windows should be normal windows. and if there are more then one windows. :bd just close the windows.

.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/14328/3661537465@github.com>

Reply all
Reply to author
Forward
0 new messages