Reimplement the bookmark comparison method

Sorting the list of user bookmarks requires care to ensure that Vim's
builtin sort function is called correctly. Previously, this function was
called incorrectly. This is why the sorting of bookmarks never worked.

The offending functions have been removed here and replaced with
"s:Bookmark.CompareBookmarksByName". To understand the necessity for
this change, read ":h sort()" for the requirements of the function
reference argument (esp., note that it must return -1, 0, or 1).

In addition to fixing this problem, the new comparison function will
inspect the "g:NERDTreeBookmarksSort" setting to determine whether
case-sensitivity is preferred in the sort. The documentation has been
modified to accurately reflect this adjustment. The change is also made
in such a way as not to break any existing configurations.

Fixes #361 ("My bookmarks aren't sorted").
This commit is contained in:
Jason Franklin
2017-05-26 13:23:05 -04:00
parent 5aec5ecfef
commit 0b65089122
3 changed files with 33 additions and 17 deletions

View File

@@ -835,11 +835,15 @@ This is where bookmarks are saved. See |NERDTreeBookmarkCommands|.
------------------------------------------------------------------------------
*'NERDTreeBookmarksSort'*
Values: 0 or 1
Values: 0, 1, or 2
Default: 1
If set to 0 then the bookmarks list is not sorted.
If set to 1 the bookmarks list is sorted.
This option controls the method by which the list of user bookmarks is
sorted. When sorted, bookmarks will render in alphabetical order by name.
If set to 0, the bookmarks list is not sorted.
If set to 1, the bookmarks list is sorted in a case-insensitive manner.
If set to 2, the bookmarks list is sorted in a case-sensitive manner.
------------------------------------------------------------------------------
*'NERDTreeMouseMode'*