Skip to content

Commit

Permalink
Merge pull request #777 from lifecrisis/bm-confirm
Browse files Browse the repository at this point in the history
Use the confirm() builtin when deleting a bookmark.
  • Loading branch information
lifecrisis authored Dec 6, 2017
2 parents b89de09 + e48ae29 commit 8cbea51
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions autoload/nerdtree/ui_glue.vim
Original file line number Diff line number Diff line change
Expand Up @@ -227,24 +227,30 @@ function! s:closeTreeWindow()
endif
endfunction

" FUNCTION: s:deleteBookmark(bm) {{{1
" if the cursor is on a bookmark, prompt to delete
function! s:deleteBookmark(bm)
echo "Are you sure you wish to delete the bookmark:\n\"" . a:bm.name . "\" (yN):"
" FUNCTION: s:deleteBookmark(bookmark) {{{1
" Prompt the user to confirm the deletion of the selected bookmark.
function! s:deleteBookmark(bookmark)
let l:message = "Delete the bookmark \"" . a:bookmark.name
\ . "\" from the bookmark list?"

if nr2char(getchar()) ==# 'y'
try
call a:bm.delete()
call b:NERDTree.root.refresh()
call b:NERDTree.render()
redraw
catch /^NERDTree/
call nerdtree#echoWarning("Could not remove bookmark")
endtry
else
call nerdtree#echo("delete aborted" )
let l:choices = "&Yes\n&No"

echo | redraw
let l:selection = confirm(l:message, l:choices, 1, 'Warning')

if l:selection != 1
call nerdtree#echo('bookmark not deleted')
return
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

" FUNCTION: s:displayHelp() {{{1
Expand Down

0 comments on commit 8cbea51

Please sign in to comment.