nerdtree

A tree explorer plugin for vim.
Index Commits Files Refs
commit 5381197747c8ead163071542c77fe76379aaf84e
parent 6b6cadf86ccce077212292b0585ab17e7884c81e
Author: Werner Hofstra <wernerhofstra@gmail.com>
Date:   Tue, 16 Oct 2018 17:08:23 +0200

Add NERDTreeRefreshRoot command (#897)

* Add NERDTreeRefreshRoot command

* Document NERDTreeRefreshRoot

Diffstat:
Mautoload/nerdtree/ui_glue.vim | 8++++++++
Mdoc/NERDTree.txt | 3+++
2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim
@@ -524,10 +524,17 @@ endfunction
 " Reloads the current root. All nodes below this will be lost and the root dir
 " will be reloaded.
 function! s:refreshRoot()
+    if !g:NERDTree.IsOpen()
+        return
+    endif
     call nerdtree#echo("Refreshing the root node. This could take a while...")
+
+    let l:curWin = winnr()
+    call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w")
     call b:NERDTree.root.refresh()
     call b:NERDTree.render()
     redraw
+    call nerdtree#exec(l:curWin . "wincmd w")
     call nerdtree#echo("Refreshing the root node. This could take a while... DONE")
 endfunction
 
@@ -554,6 +561,7 @@ function! nerdtree#ui_glue#setupCommands()
     command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreateTabTree('<args>')
     command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.CreateMirror()
     command! -n=? -complete=file -bar NERDTreeFind call s:findAndRevealPath('<args>')
+    command! -n=0 -bar NERDTreeRefreshRoot call s:refreshRoot()
     command! -n=0 -bar NERDTreeFocus call NERDTreeFocus()
     command! -n=0 -bar NERDTreeCWD call NERDTreeCWD()
 endfunction
diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt
@@ -145,6 +145,9 @@ The following features and functionality are provided by the NERD tree:
     Change the NERDTree root to the current working directory.  If no
     NERDTree exists for this tab, a new one is opened.
 
+:NERDTreeRefreshRoot                                    *:NERDTreeRefreshRoot*
+    Refreshes the NERD tree root node.
+
 ------------------------------------------------------------------------------
 2.2. Bookmarks                                             *NERDTreeBookmarks*