Restore the cached _sortKey for faster processing.
Also add a new global variable to track when the g:NERDTreeSortOrder changes. If it has been changed, or when the cached _sortKey value is uninitialized, then calculate the sort key. This improves processing speed over the previous commit, and allows on-the-fly changes to the sort order, (without required vim to be restarted.)
This commit is contained in:
parent
1e2b7ef98d
commit
e99a7a0313
@ -392,17 +392,19 @@ endfunction
|
|||||||
" FUNCTION: Path.getSortKey() {{{1
|
" FUNCTION: Path.getSortKey() {{{1
|
||||||
" returns a key used in compare function for sorting
|
" returns a key used in compare function for sorting
|
||||||
function! s:Path.getSortKey()
|
function! s:Path.getSortKey()
|
||||||
let path = self.getLastPathComponent(1)
|
if !exists("self._sortKey") || g:NERDTreeSortOrder !=# g:NERDTreeOldSortOrder
|
||||||
if !g:NERDTreeSortHiddenFirst
|
let path = self.getLastPathComponent(1)
|
||||||
let path = substitute(path, '^[._]', '', '')
|
if !g:NERDTreeSortHiddenFirst
|
||||||
endif
|
let path = substitute(path, '^[._]', '', '')
|
||||||
if !g:NERDTreeCaseSensitiveSort
|
endif
|
||||||
let path = tolower(path)
|
if !g:NERDTreeCaseSensitiveSort
|
||||||
endif
|
let path = tolower(path)
|
||||||
if !g:NERDTreeNaturalSort
|
endif
|
||||||
let self._sortKey = [self.getSortOrderIndex(), path]
|
if !g:NERDTreeNaturalSort
|
||||||
else
|
let self._sortKey = [self.getSortOrderIndex(), path]
|
||||||
let self._sortKey = [self.getSortOrderIndex()] + self._splitChunks(path)
|
else
|
||||||
|
let self._sortKey = [self.getSortOrderIndex()] + self._splitChunks(path)
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return self._sortKey
|
return self._sortKey
|
||||||
|
@ -612,6 +612,7 @@ function! s:TreeDirNode.sortChildren()
|
|||||||
endif
|
endif
|
||||||
let CompareFunc = function("nerdtree#compareNodesBySortKey")
|
let CompareFunc = function("nerdtree#compareNodesBySortKey")
|
||||||
call sort(self.children, CompareFunc)
|
call sort(self.children, CompareFunc)
|
||||||
|
let g:NERDTreeOldSortOrder = g:NERDTreeSortOrder
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: TreeDirNode.toggleOpen([options]) {{{1
|
" FUNCTION: TreeDirNode.toggleOpen([options]) {{{1
|
||||||
|
@ -82,6 +82,7 @@ call s:initVariable("g:NERDTreeCascadeSingleChildDir", 1)
|
|||||||
if !exists("g:NERDTreeSortOrder")
|
if !exists("g:NERDTreeSortOrder")
|
||||||
let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$']
|
let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$']
|
||||||
endif
|
endif
|
||||||
|
let g:NERDTreeOldSortOrder = []
|
||||||
|
|
||||||
call s:initVariable("g:NERDTreeGlyphReadOnly", "RO")
|
call s:initVariable("g:NERDTreeGlyphReadOnly", "RO")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user