bufferline.nvim icon indicating copy to clipboard operation
bufferline.nvim copied to clipboard

Prevent unsaved buffers to be closed without confirmation

Open jpoppe opened this issue 2 years ago • 3 comments

Removed default force flag (!) from bdelete and 'api.nvim_buf_delete' commands.

I don't know if it is intentional but IMHO force deleting buffers is not a user friendly default.

I lost quite some work today by using the default configuration and using the BufferLineCloseLeft and BufferLineCloseRight and not expecting it would close unsaved buffers without confirmation.


If the intended behavior is force deleting buffers please feel free to close this pull request and maybe you could add a warning to the README that it force deletes buffers, thanks!

jpoppe avatar Jun 13 '22 20:06 jpoppe

See also: #279

jpoppe avatar Jun 13 '22 20:06 jpoppe

@jpoppe this relates also to #438 where there is a similar request. So this was definitely by choice since current behaviour is definitely my preference. As I mention though I'm happy to have this be configurable and my suggestion in the issue I linked was that if a bang is passed in the command it should force a deletion otherwise it shouldn't.

With the addition of lua commands this is now much easier since you only need to check the args table passed in to the CloseRight/Left commands and see if bang = true if so pass that to the delete function

akinsho avatar Jun 13 '22 20:06 akinsho

Thanks for your fast reply! This was indeed a quick fix on my side and it would be of course nicer if it's configurable.more flexible, was just trying this plugin and did not expect this behavior. And I missed #438 in my searches 🤔 .

jpoppe avatar Jun 13 '22 21:06 jpoppe

This feature has now been merged into the dev branch

akinsho avatar Sep 26 '22 08:09 akinsho