From 35ff820273163f02402560235f10330825798aef Mon Sep 17 00:00:00 2001 From: "Phil Runninger (mac)" Date: Wed, 17 Oct 2018 17:14:36 -0400 Subject: [PATCH] Force sort to recalculate the cached sortKey. The problem in issue #880 was caused by the sort using the old sortKey. For example, given nodes A, B, and C, if B were renamed to D, the sort was still using B as its sortKey, thus not moving it. It's a bit of a hack, but if we set g:NERDTreeOldSortOrder to an empty list, the cached sortKey will be recalculated. I did the same thing for both the Copy and Add functions as well. --- nerdtree_plugin/fs_menu.vim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index f6249f93..73f3e2b9 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -128,6 +128,7 @@ function! NERDTreeAddNode() let parentNode = b:NERDTree.root.findNode(newPath.getParent()) let newTreeNode = g:NERDTreeFileNode.New(newPath, b:NERDTree) + let g:NERDTreeOldSortOrder = [] if empty(parentNode) call b:NERDTree.root.refresh() call b:NERDTree.render() @@ -158,6 +159,7 @@ function! NERDTreeMoveNode() let bufnum = bufnr("^".curNode.path.str()."$") call curNode.rename(newNodePath) + let g:NERDTreeOldSortOrder = [] call b:NERDTree.root.refresh() call NERDTreeRender() @@ -283,6 +285,7 @@ function! NERDTreeCopyNode() if confirmed try let newNode = currentNode.copy(newNodePath) + let g:NERDTreeOldSortOrder = [] if empty(newNode) call b:NERDTree.root.refresh() call b:NERDTree.render()