mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-09 11:53:48 -05:00
Recalculate the node's sortkey every time.
The cached _sortkey wasn't being recalculated after changing the NERDTreeSortOrder, resulting in incorrect sort orders.
This commit is contained in:
@@ -7,10 +7,6 @@
|
||||
" ============================================================================
|
||||
|
||||
|
||||
" This constant is used throughout this script for sorting purposes.
|
||||
let s:NERDTreeSortStarIndex = index(g:NERDTreeSortOrder, '*')
|
||||
lockvar s:NERDTreeSortStarIndex
|
||||
|
||||
let s:Path = {}
|
||||
let g:NERDTreePath = s:Path
|
||||
|
||||
@@ -374,7 +370,8 @@ function! s:Path.getSortOrderIndex()
|
||||
endif
|
||||
let i = i + 1
|
||||
endwhile
|
||||
return s:NERDTreeSortStarIndex
|
||||
|
||||
return index(g:NERDTreeSortOrder, '*')
|
||||
endfunction
|
||||
|
||||
" FUNCTION: Path._splitChunks(path) {{{1
|
||||
@@ -395,7 +392,6 @@ endfunction
|
||||
" FUNCTION: Path.getSortKey() {{{1
|
||||
" returns a key used in compare function for sorting
|
||||
function! s:Path.getSortKey()
|
||||
if !exists("self._sortKey")
|
||||
let path = self.getLastPathComponent(1)
|
||||
if !g:NERDTreeSortHiddenFirst
|
||||
let path = substitute(path, '^[._]', '', '')
|
||||
@@ -408,7 +404,6 @@ function! s:Path.getSortKey()
|
||||
else
|
||||
let self._sortKey = [self.getSortOrderIndex()] + self._splitChunks(path)
|
||||
endif
|
||||
endif
|
||||
|
||||
return self._sortKey
|
||||
endfunction
|
||||
|
||||
@@ -607,6 +607,7 @@ endfunction
|
||||
" FUNCTION: TreeDirNode.sortChildren() {{{1
|
||||
" Sort "self.children" by alphabetical order and directory priority.
|
||||
function! s:TreeDirNode.sortChildren()
|
||||
call AddDefaultGroupToSortOrder()
|
||||
let CompareFunc = function("nerdtree#compareNodesBySortKey")
|
||||
call sort(self.children, CompareFunc)
|
||||
endfunction
|
||||
|
||||
Reference in New Issue
Block a user