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

Doesn't support "set confirm" #15

Open
rsheasby opened this issue Feb 15, 2019 · 3 comments
Open

Doesn't support "set confirm" #15

rsheasby opened this issue Feb 15, 2019 · 3 comments

Comments

@rsheasby
Copy link

Hi there.

Loving the plugin. Makes everything infinitely easier and better behaved. The only issue I have right now is that it doesn't support vim's "confirm" option which will prompt on closing an unsaved buffer instead of asking for an exclamation mark. It's extremely handy and would be vastly preferred to the current method(which requires a separate key mapping for force closing).

@gibfahn
Copy link

gibfahn commented Dec 30, 2023

For anyone else coming across this, I have the same problem (on neovim), and resolved it by switching to https://github.com/famiu/bufdelete.nvim , which also provides Bdelete and prompts if needed.

@jimafisk
Copy link

It looks like the (add ! to override) error is being thrown here:

if getbufvar(buffer, "&modified") && empty(a:bang)

If you have set confirm in your ~/.config/nvim/init.vim you should be able to modify ~/.config/nvim/plugged/vim-bbye/plugin/bbye.vim to only throw that if confirm is not enabled:

if getbufvar(buffer, "&modified") && empty(a:bang)
   if !&confirm
     let error = "E89: No write since last change for buffer "
     return s:error(error . buffer . " (add ! to override)")
   endif
endif

This got [Y]es and (N)o working for me, unfortunately (C)ancel throws errors like:

Error detected while processing function <SNR>19_bdelete:
line   50:
E516: No buffers were deleted: bdelete 7

@jimafisk
Copy link

This doesn't respect the set confirm in your config, but adding my own confirm logic into the plugin seems to work better in general. You can do that in the same section I mentioned above like this:

if getbufvar(buffer, "&modified") && empty(a:bang)                        
   let confirm_result = confirm("Save changes?", "&Yes\n&No\n&Cancel", 3)
   if confirm_result == 1                                                
      write                                                             
      echo "Changes Saved"                                              
   elseif confirm_result == 2                                            
      edit!                                                             
      echo "Changes Discarded"                                          
   else                                                                  
      echo "Resume Editing"                                             
      return                                                            
   endif                                                              
endif

jimafisk added a commit to jimafisk/vim-bbye that referenced this issue May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants