From b37495fa985794b1a8d1b4bee6232fc42c7ca8d8 Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Mon, 2 Apr 2018 09:26:34 -0400 Subject: [PATCH] If node isn't open, count children on disk before deleting. Fixes #821. If a node isn't opened in NERDTree, it's children aren't known yet, so when deleting the node (with `m`, `d`), the user isn't properly asked to confirm the delete. It was going to the less strict `Y`/`n` confirmation, instead of the `yes` confirmation for non-empty directories. This change checks to see if the node is opened already. If it is, the existing getChildCount() function is used; otherwise, the disk is read to get the number of children there. --- nerdtree_plugin/fs_menu.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 928d8a2..c91624d 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -175,7 +175,8 @@ function! NERDTreeDeleteNode() let currentNode = g:NERDTreeFileNode.GetSelected() let confirmed = 0 - if currentNode.path.isDirectory && currentNode.getChildCount() > 0 + if currentNode.path.isDirectory && ((currentNode.isOpen && currentNode.getChildCount() > 0) || + \ (len(currentNode._glob('*', 1)) > 0)) let choice =input("Delete the current node\n" . \ "==========================================================\n" . \ "STOP! Directory is not empty! To delete, type 'yes'\n" .