diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 71be5f5..0aa592e 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -392,17 +392,19 @@ endfunction " FUNCTION: Path.getSortKey() {{{1 " returns a key used in compare function for sorting function! s:Path.getSortKey() - let path = self.getLastPathComponent(1) - if !g:NERDTreeSortHiddenFirst - let path = substitute(path, '^[._]', '', '') - endif - if !g:NERDTreeCaseSensitiveSort - let path = tolower(path) - endif - if !g:NERDTreeNaturalSort - let self._sortKey = [self.getSortOrderIndex(), path] - else - let self._sortKey = [self.getSortOrderIndex()] + self._splitChunks(path) + if !exists("self._sortKey") || g:NERDTreeSortOrder !=# g:NERDTreeOldSortOrder + let path = self.getLastPathComponent(1) + if !g:NERDTreeSortHiddenFirst + let path = substitute(path, '^[._]', '', '') + endif + if !g:NERDTreeCaseSensitiveSort + let path = tolower(path) + endif + if !g:NERDTreeNaturalSort + let self._sortKey = [self.getSortOrderIndex(), path] + else + let self._sortKey = [self.getSortOrderIndex()] + self._splitChunks(path) + endif endif return self._sortKey diff --git a/lib/nerdtree/tree_dir_node.vim b/lib/nerdtree/tree_dir_node.vim index 2f62ec3..30db853 100644 --- a/lib/nerdtree/tree_dir_node.vim +++ b/lib/nerdtree/tree_dir_node.vim @@ -612,6 +612,7 @@ function! s:TreeDirNode.sortChildren() endif let CompareFunc = function("nerdtree#compareNodesBySortKey") call sort(self.children, CompareFunc) + let g:NERDTreeOldSortOrder = g:NERDTreeSortOrder endfunction " FUNCTION: TreeDirNode.toggleOpen([options]) {{{1 diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index a8af089..71d719a 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -82,6 +82,7 @@ call s:initVariable("g:NERDTreeCascadeSingleChildDir", 1) if !exists("g:NERDTreeSortOrder") let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$'] endif +let g:NERDTreeOldSortOrder = [] call s:initVariable("g:NERDTreeGlyphReadOnly", "RO")