commit 3a7694aa555f2b421ce6d685c0a8f19861161ed9
parent 1f089a362b859f8879f70f1ccdb7e40d1e5ba822
Author: Jason Franklin <j_fra@fastmail.us>
Date: Fri, 14 Jul 2017 17:52:00 -0400
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.
Diffstat:
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim
@@ -293,15 +293,17 @@ function! s:Bookmark.str()
endfunction
" 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)
if self.validate()
try
- let targetNode = self.getNode(a:nerdtree, 1)
+ let l:targetNode = self.getNode(a:nerdtree, 1)
+ call l:targetNode.closeChildren()
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
- call a:nerdtree.changeRoot(targetNode)
+ call a:nerdtree.changeRoot(l:targetNode)
endif
endfunction