mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-10 04:13:48 -05:00
Refactor sort comparison functions, removing redundancy (#1166)
* Add a function to compare path objects. * Remove redundant node comparison function, and rename the ones left. * Remove the compareTo function in the Path object. Use nerdtree#compareNodePaths(p1,p2) instead. There was no need for two comparison functions that do the same thing. They were a little different in their details, but that shouldn't be the case. Having only one such function makes better sense and is easier to maintain. * Update version number in change log.
This commit is contained in:
@@ -110,15 +110,15 @@ function! nerdtree#completeBookmarks(A,L,P) abort
|
||||
return filter(g:NERDTreeBookmark.BookmarkNames(), 'v:val =~# "^' . a:A . '"')
|
||||
endfunction
|
||||
|
||||
"FUNCTION: nerdtree#compareNodes(dir) {{{2
|
||||
"FUNCTION: nerdtree#compareNodes(n1, n2) {{{2
|
||||
function! nerdtree#compareNodes(n1, n2) abort
|
||||
return a:n1.path.compareTo(a:n2.path)
|
||||
return nerdtree#compareNodePaths(a:n1.path, a:n2.path)
|
||||
endfunction
|
||||
|
||||
"FUNCTION: nerdtree#compareNodesBySortKey(n1, n2) {{{2
|
||||
function! nerdtree#compareNodesBySortKey(n1, n2) abort
|
||||
let sortKey1 = a:n1.path.getSortKey()
|
||||
let sortKey2 = a:n2.path.getSortKey()
|
||||
"FUNCTION: nerdtree#compareNodePaths(p1, p2) {{{2
|
||||
function! nerdtree#compareNodePaths(p1, p2) abort
|
||||
let sortKey1 = a:p1.getSortKey()
|
||||
let sortKey2 = a:p2.getSortKey()
|
||||
let i = 0
|
||||
while i < min([len(sortKey1), len(sortKey2)])
|
||||
" Compare chunks upto common length.
|
||||
|
||||
Reference in New Issue
Block a user