Skip to content

Commit

Permalink
Confirm to Save/Discard/Resume changes (moll#15).
Browse files Browse the repository at this point in the history
  • Loading branch information
jimafisk committed May 31, 2024
1 parent 25ef93a commit 3924722
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions plugin/bbye.vim
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,17 @@ function! s:bdelete(action, bang, buffer_name)
endif

if getbufvar(buffer, "&modified") && empty(a:bang)
let error = "E89: No write since last change for buffer "
return s:error(error . buffer . " (add ! to override)")
let confirm_result = confirm("Save changes?", "&Yes\n&No\n&Cancel", 3)
if confirm_result == 1
write
echo "Save Changes"
elseif confirm_result == 2
edit!
echo "Discard Changes"
else
echo "Resume Editing"
return
endif
endif

" If the buffer is set to delete and it contains changes, we can't switch
Expand Down

0 comments on commit 3924722

Please sign in to comment.