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.
This commit is contained in:
Phil Runninger (mac) 2018-04-02 09:26:34 -04:00
parent a172d7cfcb
commit b37495fa98

View File

@ -175,7 +175,8 @@ function! NERDTreeDeleteNode()
let currentNode = g:NERDTreeFileNode.GetSelected() let currentNode = g:NERDTreeFileNode.GetSelected()
let confirmed = 0 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" . let choice =input("Delete the current node\n" .
\ "==========================================================\n" . \ "==========================================================\n" .
\ "STOP! Directory is not empty! To delete, type 'yes'\n" . \ "STOP! Directory is not empty! To delete, type 'yes'\n" .