mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-09 11:53:48 -05:00
sort bookmarks when we add a new one
This commit is contained in:
@@ -166,6 +166,7 @@ function! s:oBookmark.AddBookmark(name, path) dict
|
|||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
call add(s:oBookmark.Bookmarks(), s:oBookmark.New(a:name, a:path))
|
call add(s:oBookmark.Bookmarks(), s:oBookmark.New(a:name, a:path))
|
||||||
|
call s:oBookmark.Sort()
|
||||||
endfunction
|
endfunction
|
||||||
" Function: oBookmark.Bookmarks() {{{3
|
" Function: oBookmark.Bookmarks() {{{3
|
||||||
" Class method to get all bookmarks. Lazily initializes the bookmarks global
|
" Class method to get all bookmarks. Lazily initializes the bookmarks global
|
||||||
@@ -222,6 +223,11 @@ function! s:oBookmark.CacheBookmarks() dict
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
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
|
" FUNCTION: oBookmark.ClearAll() {{{3
|
||||||
" Class method to delete all bookmarks.
|
" Class method to delete all bookmarks.
|
||||||
function! s:oBookmark.ClearAll() dict
|
function! s:oBookmark.ClearAll() dict
|
||||||
@@ -280,6 +286,12 @@ function! s:oBookmark.New(name, path) dict
|
|||||||
let newBookmark.path = a:path
|
let newBookmark.path = a:path
|
||||||
return newBookmark
|
return newBookmark
|
||||||
endfunction
|
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
|
" Function: oBookmark.Str() {{{3
|
||||||
" Get the string that should be rendered in the view for this bookmark
|
" Get the string that should be rendered in the view for this bookmark
|
||||||
function! s:oBookmark.Str() dict
|
function! s:oBookmark.Str() dict
|
||||||
@@ -1581,6 +1593,12 @@ function! s:BufInWindows(bnum)
|
|||||||
return cnt
|
return cnt
|
||||||
endfunction " >>>
|
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
|
" FUNCTION: s:CompleteBookmarks(A,L,P) {{{2
|
||||||
" completion function for the bookmark commands
|
" completion function for the bookmark commands
|
||||||
function! s:CompleteBookmarks(A,L,P)
|
function! s:CompleteBookmarks(A,L,P)
|
||||||
|
|||||||
Reference in New Issue
Block a user