romgrk / barbar.nvim

The neovim tabline plugin.
2.16k stars 81 forks source link

Closing a term buffer with BufferClose errors requiring a ! to override #537

Closed SamuilDichev closed 7 months ago

SamuilDichev commented 7 months ago

Description

Trying to close a :term buffer with :BufferClose tells me it will be killed and that I need to add ! to override. On the other hand, clicking the X in the UI, prompts me whether I really want to close it or not. Which sounds more desirable.

So UI closure works fine, just not :BufferClose. I would have assumed they'd do the same thing internally, but I guess not?

To Reproduce

  1. Do :term and open a terminal in a new "tab" / buffer
  2. Do :BufferClose

Screenshots Pressing the X in UI works like so: image

Note: It switches to the left tab before I've confirmed the prompt. Should it? Seems premature. Is that another bug?

And :BufferClose image

Informations Neovim version: v0.10.0-dev

Iron-E commented 7 months ago

As you intuited, the close button and close command do indeed have different functionality.

The commands provided by this plugin were designed with the intention of being familiar for those who know the builtin Vim buffer commands (:bdelete, :bwipeout, :bnext, :bprevious, etc). For example:

bd foo " close buffer 'foo'
BufferClose foo " close buffer 'foo', preserving layout
bd! foo " force close buffer 'foo'
BufferClose! foo " force close buffer 'foo', preserving layout

However when clicking the UI there's no way to distinguish between a click to "close" and a click to "force close" (at least not in Vim, that I know of), which is where the dialogue came from.

We could certainly investigate adding a new command or config setting which enables this interactivity elsewhere.

Note: It switches to the left tab before I've confirmed the prompt. Should it? Seems premature. Is that another bug?

I'll have to investigate this, thank you for bringing it to my attention!

Iron-E commented 7 months ago

I did a little digging, turns out this already exists!

Just do this:

confirm BufferClose
SamuilDichev commented 7 months ago

That's it! Works perfect, thanks!