From ac94cd28c22b9f26f429390aa8871a36711dc31e Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sun, 19 Nov 2017 16:37:54 -0500 Subject: [PATCH] Make the "o" mapping consistent with "x" The "o" mapping, which toggles directory nodes open/closed, allowed the user to close the tree root. This was not consistent with the "x" mapping which stops the user from doing this. This applies to a double-click on the root node as well. It should be noted that, if the root node is somehow closed, "o" and double click can still re-open the tree, even with this change. In other words, I was careful. --- autoload/nerdtree/ui_glue.vim | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/autoload/nerdtree/ui_glue.vim b/autoload/nerdtree/ui_glue.vim index 93ac567..689b784 100644 --- a/autoload/nerdtree/ui_glue.vim +++ b/autoload/nerdtree/ui_glue.vim @@ -90,10 +90,15 @@ function! s:activateAll() endif endfunction -"FUNCTION: s:activateDirNode() {{{1 -"handle the user activating a tree node -function! s:activateDirNode(node) - call a:node.activate() +" FUNCTION: s:activateDirNode(directoryNode) {{{1 +function! s:activateDirNode(directoryNode) + + if a:directoryNode.isRoot() && a:directoryNode.isOpen + call nerdtree#echo('cannot close tree root') + return + endif + + call a:directoryNode.activate() endfunction "FUNCTION: s:activateFileNode() {{{1