From e48b5728f921cfd745514499e29afdc200b992bc Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Tue, 28 Jan 2020 03:55:58 -0500 Subject: [PATCH] NERDTree always sets NERDTree root. --- CHANGELOG.md | 2 ++ doc/NERDTree.txt | 5 +++-- lib/nerdtree/creator.vim | 13 ++++++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index edbcfae..873cb29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ in an unordered list. The format is: - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> +#### 6.5 +- **.0**: `NERDTreeToggle ` always sets NERDTree root. (PhilRunninger) [#1082](https://github.com/preservim/nerdtree/pull/1082) #### 6.4 - **.6**: NERDTreeFind shows expected message if file doesn't exist e.g. with vim-startify (andys8). [#1081](https://github.com/preservim/nerdtree/pull/1081) - **.5**: Ensure events are (or aren't) being ignored correctly. (PhilRunninger) [#1080](https://github.com/preservim/nerdtree/pull/1080) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 857e682..e2dd56a 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -122,8 +122,9 @@ The following features and functionality are provided by the NERDTree: :NERDTreeToggle [ | ] *:NERDTreeToggle* If a NERDTree already exists for this tab, it is reopened and rendered - again. If no NERDTree exists for this tab then this command acts the - same as the |:NERDTree| command. + again. If or is given, the root of NERDTree + is set to that path. If no NERDTree exists for this tab then this command + acts the same as the |:NERDTree| command. :NERDTreeToggleVCS [ | ] *:NERDTreeToggleVCS* Like |:NERDTreeToggle|, but searches up the directory tree to find the top of diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 67fd3ce..e2b3fa0 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -355,17 +355,20 @@ function! s:Creator.ToggleTabTree(dir) endfunction " FUNCTION: s:Creator.toggleTabTree(dir) {{{1 -" Toggles the NERD tree. I.e the NERD tree is open, it is closed, if it is -" closed it is restored or initialized (if it doesnt exist) +" Toggles the NERD tree. I.e if the NERD tree is open, it is closed. If it is +" closed, it is restored or initialized. If dir is not empty, it will be set +" as the new root. " " Args: -" dir: the full path for the root node (is only used if the NERD tree is being -" initialized. +" dir: the full path for the root node (is used if the NERD tree is being +" initialized, or to change the root to a new dir.) function! s:Creator.toggleTabTree(dir) if g:NERDTree.ExistsForTab() if !g:NERDTree.IsOpen() call self._createTreeWin() - if !&hidden + if !empty(a:dir) + call self.createTabTree(a:dir) + elseif !&hidden call b:NERDTree.render() endif call b:NERDTree.ui.restoreScreenState()