Skip to content

Commit

Permalink
Force sort to recalculate the cached sortKey.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Phil Runninger (mac) committed Oct 17, 2018
1 parent 5381197 commit 35ff820
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions nerdtree_plugin/fs_menu.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 35ff820

Please sign in to comment.