Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: allow cancelling of bufdelete closing of multiple buffers #1513

Open
1 task done
acidclouds opened this issue Mar 6, 2025 · 0 comments · May be fixed by #1514
Open
1 task done

feature: allow cancelling of bufdelete closing of multiple buffers #1513

acidclouds opened this issue Mar 6, 2025 · 0 comments · May be fixed by #1514
Labels
enhancement New feature or request

Comments

@acidclouds
Copy link
Contributor

acidclouds commented Mar 6, 2025

Did you check the docs?

  • I have read all the snacks.nvim docs

Is your feature request related to a problem? Please describe.

When using bufdelete close all on multiple unsaved buffers, and choosing cancel when the prompt shows up, bufdelete continues to try to close the following buffers as well.
This behavior is a little strange, if I would want to save the buffer, I would have chosen yes, if I wanted to discard the changes, I would have chosen no. If I chose cancel/Ctrl-C the logical thing would be cancel the whole bulk operation and let the user perform any modifications they might deem necessary before proceeding.

This would allow a user to define an autocommand on PreExit to call bufdelete all and get a prompt for each unsaved buffer, deciding if he would like to save the changes or not, and also allowing to cancel the whole operation and stop nvim from exiting. This behavior is the normal behavior in numerous application including office applications preventing unintentional data loss.

Describe the solution you'd like

I will be publishing a PR shortly with the change I am proposing.
The solution would be to stop bufdelete from trying to close any additional buffers after a user selects Cancel once or hits Ctrl-C

Describe alternatives you've considered

I can try to call bufdelete on each buffer separately during my autocommand, however isn't the bufdelete all functionality does exactly that?

Additional context

vim.api.nvim_create_autocmd({ "QuitPre" }, {
	callback = function(context)
		Snacks.bufdelete.all()
	end,
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
1 participant