mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-09 03:43:50 -05:00
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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user