Update the delete bookmark map to use confirm()

I contend that we should use confirm() whenever possible.  It makes
the code cleaner and uses a builtin feature rather than a custom
one.  Doing it the "Vim way" is always preferable in my mind.
This commit is contained in:
Jason Franklin 2017-12-01 08:45:18 -05:00
parent b89de09810
commit e48ae299f9

View File

@ -227,24 +227,30 @@ function! s:closeTreeWindow()
endif endif
endfunction endfunction
" FUNCTION: s:deleteBookmark(bm) {{{1 " FUNCTION: s:deleteBookmark(bookmark) {{{1
" if the cursor is on a bookmark, prompt to delete " Prompt the user to confirm the deletion of the selected bookmark.
function! s:deleteBookmark(bm) function! s:deleteBookmark(bookmark)
echo "Are you sure you wish to delete the bookmark:\n\"" . a:bm.name . "\" (yN):" let l:message = "Delete the bookmark \"" . a:bookmark.name
\ . "\" from the bookmark list?"
if nr2char(getchar()) ==# 'y' let l:choices = "&Yes\n&No"
try
call a:bm.delete() echo | redraw
call b:NERDTree.root.refresh() let l:selection = confirm(l:message, l:choices, 1, 'Warning')
call b:NERDTree.render()
redraw if l:selection != 1
catch /^NERDTree/ call nerdtree#echo('bookmark not deleted')
call nerdtree#echoWarning("Could not remove bookmark") return
endtry
else
call nerdtree#echo("delete aborted" )
endif endif
try
call a:bookmark.delete()
silent call b:NERDTree.root.refresh()
call b:NERDTree.render()
echo | redraw
catch /^NERDTree/
call nerdtree#echoWarning('could not remove bookmark')
endtry
endfunction endfunction
" FUNCTION: s:displayHelp() {{{1 " FUNCTION: s:displayHelp() {{{1