diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 2aa3bec..2478fd3 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -441,21 +441,19 @@ function! s:jumpToSibling(currentNode, forward) endfunction " FUNCTION: nerdtree#ui_glue#openBookmark(name) {{{1 -" put the cursor on the given bookmark and, if its a file, open it +" Open the Bookmark that has the specified name. This function provides the +" implementation for the ":OpenBookmark" command. function! nerdtree#ui_glue#openBookmark(name) try - let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0, b:NERDTree) - call targetNode.putCursorHere(0, 1) - redraw! - catch /^NERDTree.BookmarkedNodeNotFoundError/ - call nerdtree#echo("note - target node is not cached") - let bookmark = g:NERDTreeBookmark.BookmarkFor(a:name) - let targetNode = g:NERDTreeFileNode.New(bookmark.path, b:NERDTree) + let l:bookmark = g:NERDTreeBookmark.BookmarkFor(a:name) + catch /^NERDTree.BookmarkNotFoundError/ + call nerdtree#echoError('bookmark "' . a:name . '" not found') + return endtry - if targetNode.path.isDirectory - call targetNode.openExplorer() + if l:bookmark.path.isDirectory + call l:bookmark.open(b:NERDTree) else - call targetNode.open({'where': 'p'}) + call l:bookmark.open(b:NERDTree, {'where': 'p'}) endif endfunction diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index d50cfb2..e976615 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -158,7 +158,7 @@ click bookmarks or use the |NERDTree-o| mapping to activate them. See also, ------------------------------------------------------------------------------ 2.2.2. Bookmark commands *NERDTreeBookmarkCommands* -Note that the following commands are only available in the NERD tree buffer. +Note: The following commands are only available within the NERDTree buffer. :Bookmark [] Bookmark the current node as . If there is already a @@ -178,10 +178,11 @@ Note that the following commands are only available in the NERD tree buffer. (i.e. directory nodes above it will be opened) and the cursor will be placed on it. -:OpenBookmark - must point to a file. The file is opened as though |NERDTree-o| - was applied. If the node is cached under the current root then it will be - revealed and the cursor will be placed on it. +:OpenBookmark + The Bookmark named is opened as if |NERDTree-o| was applied to + its entry in the Bookmark table. If the Bookmark points to a directory, + it is made the new root of the current NERDTree. If the Bookmark points + to a file, that file is opened for editing in another window. :ClearBookmarks [] Remove all the given bookmarks. If no bookmarks are given then remove all diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 952811c..92e1abe 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -14,7 +14,7 @@ function! s:Creator._bindMappings() command! -buffer -nargs=? Bookmark :call nerdtree#ui_glue#bookmarkNode('') command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 RevealBookmark :call nerdtree#ui_glue#revealBookmark('') - command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 OpenBookmark :call nerdtree#ui_glue#openBookmark('') + command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 OpenBookmark call nerdtree#ui_glue#openBookmark('') command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=* ClearBookmarks call nerdtree#ui_glue#clearBookmarks('') command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=+ BookmarkToRoot call g:NERDTreeBookmark.ToRoot('', b:NERDTree) command! -buffer -nargs=0 ClearAllBookmarks call g:NERDTreeBookmark.ClearAll() call b:NERDTree.render()