diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 907ad4a..29dc9cd 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -682,7 +682,8 @@ the NERD tree. These settings should be set in your vimrc, using `:let`. |NERDTreeMouseMode| Manage the interpretation of mouse clicks. -|NERDTreeQuitOnOpen| Closes the tree window after opening a file. +|NERDTreeQuitOnOpen| Closes the tree window or bookmark table after + opening a file. |NERDTreeShowBookmarks| Tells the NERD tree whether to display the bookmarks table on startup. @@ -959,11 +960,19 @@ then (to single click activate it) you must click somewhere in ------------------------------------------------------------------------------ *NERDTreeQuitOnOpen* -Values: 0 or 1. +Values: 0,1,2 or 3. Default: 0 -If set to 1, the NERD tree window will close after opening a file with the -|NERDTree-o|, |NERDTree-i|, |NERDTree-t| and |NERDTree-T| mappings. +This setting governs whether the NERDTree window or the bookmarks table closes +after opening a file with the |NERDTree-o|, |NERDTree-i|, |NERDTree-t| and +|NERDTree-T| mappings. + + Value | NERDTree Window Behavior + -------+------------------------------------------------------- + 0 | No change + 1 | Closes after opening a file + 2 | Closes the bookmark table after opening a bookmark + 3(1+2) | Same as both 1 and 2 ------------------------------------------------------------------------------ *NERDTreeShowBookmarks* diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index c256aaf..dad3dc8 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -256,6 +256,10 @@ endfunction function! s:Bookmark.open(nerdtree, ...) let opts = a:0 ? a:1 : {} + if and(g:NERDTreeQuitOnOpen,2) + call a:nerdtree.ui.toggleShowBookmarks() + endif + if self.path.isDirectory && !has_key(opts, 'where') call self.toRoot(a:nerdtree) else diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index fcabcb9..5a4ebc5 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -66,7 +66,7 @@ endfunction "FUNCTION: s:NERDTree.CloseIfQuitOnOpen() {{{1 "Closes the NERD tree window if the close on open option is set function! s:NERDTree.CloseIfQuitOnOpen() - if g:NERDTreeQuitOnOpen && s:NERDTree.IsOpen() + if and(g:NERDTreeQuitOnOpen,1) && s:NERDTree.IsOpen() call s:NERDTree.Close() endif endfunction diff --git a/lib/nerdtree/opener.vim b/lib/nerdtree/opener.vim index ef357ef..f4bd6e0 100644 --- a/lib/nerdtree/opener.vim +++ b/lib/nerdtree/opener.vim @@ -243,7 +243,7 @@ endfunction " FUNCTION: Opener._openFile() {{{1 function! s:Opener._openFile() - if !self._stay && !g:NERDTreeQuitOnOpen && exists("b:NERDTreeZoomed") && b:NERDTreeZoomed + if !self._stay && !and(g:NERDTreeQuitOnOpen,1) && exists("b:NERDTreeZoomed") && b:NERDTreeZoomed call b:NERDTree.ui.toggleZoom() endif