mirror of
https://github.com/preservim/nerdtree.git
synced 2025-03-04 04:45:27 +08:00
sort bookmarks when we add a new one
This commit is contained in:
parent
02facac20a
commit
030cff2eda
@ -166,6 +166,7 @@ function! s:oBookmark.AddBookmark(name, path) dict
|
||||
endif
|
||||
endfor
|
||||
call add(s:oBookmark.Bookmarks(), s:oBookmark.New(a:name, a:path))
|
||||
call s:oBookmark.Sort()
|
||||
endfunction
|
||||
" Function: oBookmark.Bookmarks() {{{3
|
||||
" Class method to get all bookmarks. Lazily initializes the bookmarks global
|
||||
@ -222,6 +223,11 @@ function! s:oBookmark.CacheBookmarks() dict
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
" FUNCTION: oBookmark.CompareTo(otherbookmark) {{{3
|
||||
" Compare these two bookmarks for sorting purposes
|
||||
function! s:oBookmark.CompareTo(otherbookmark) dict
|
||||
return a:otherbookmark.name < self.name
|
||||
endfunction
|
||||
" FUNCTION: oBookmark.ClearAll() {{{3
|
||||
" Class method to delete all bookmarks.
|
||||
function! s:oBookmark.ClearAll() dict
|
||||
@ -280,6 +286,12 @@ function! s:oBookmark.New(name, path) dict
|
||||
let newBookmark.path = a:path
|
||||
return newBookmark
|
||||
endfunction
|
||||
" Function: oBookmark.Sort() {{{3
|
||||
" Class method that sorts all bookmarks
|
||||
function! s:oBookmark.Sort() dict
|
||||
let CompareFunc = function("s:CompareBookmarks")
|
||||
call sort(s:oBookmark.Bookmarks(), CompareFunc)
|
||||
endfunction
|
||||
" Function: oBookmark.Str() {{{3
|
||||
" Get the string that should be rendered in the view for this bookmark
|
||||
function! s:oBookmark.Str() dict
|
||||
@ -1581,6 +1593,12 @@ function! s:BufInWindows(bnum)
|
||||
return cnt
|
||||
endfunction " >>>
|
||||
|
||||
"FUNCTION: CompareBookmarks(first, second) {{{2
|
||||
"Compares two bookmarks
|
||||
function! s:CompareBookmarks(first, second)
|
||||
return a:first.CompareTo(a:second)
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:CompleteBookmarks(A,L,P) {{{2
|
||||
" completion function for the bookmark commands
|
||||
function! s:CompleteBookmarks(A,L,P)
|
||||
|
Loading…
x
Reference in New Issue
Block a user