Add a call to close the children of bookmarks

When bookmarks are opened normally (i.e., when a bookmark is made
the root of the current NERDTree), any open children of that
bookmark will remain open.

This is often inconvenient, especially for users who want bookmarks
to appear "fresh" when opened.
This commit is contained in:
Jason Franklin
2017-07-14 17:52:00 -04:00
parent 1f089a362b
commit 3a7694aa55

View File

@@ -293,15 +293,17 @@ function! s:Bookmark.str()
endfunction endfunction
" FUNCTION: Bookmark.toRoot(nerdtree) {{{1 " FUNCTION: Bookmark.toRoot(nerdtree) {{{1
" Make the node for this bookmark the new tree root " Set the root of the given NERDTree to the node for this Bookmark. If a node
" for this Bookmark does not exist, a new one is initialized.
function! s:Bookmark.toRoot(nerdtree) function! s:Bookmark.toRoot(nerdtree)
if self.validate() if self.validate()
try try
let targetNode = self.getNode(a:nerdtree, 1) let l:targetNode = self.getNode(a:nerdtree, 1)
call l:targetNode.closeChildren()
catch /^NERDTree.BookmarkedNodeNotFoundError/ catch /^NERDTree.BookmarkedNodeNotFoundError/
let targetNode = g:NERDTreeFileNode.New(s:Bookmark.BookmarkFor(self.name).path, a:nerdtree) let l:targetNode = g:NERDTreeFileNode.New(s:Bookmark.BookmarkFor(self.name).path, a:nerdtree)
endtry endtry
call a:nerdtree.changeRoot(targetNode) call a:nerdtree.changeRoot(l:targetNode)
endif endif
endfunction endfunction