Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUGFIX: Broken "g:NERDTreeBookmarksSort" setting fixed. #696

Merged
merged 4 commits into from
May 26, 2017

Conversation

lifecrisis
Copy link
Contributor

The feature that is supposed to allow users' bookmarks to be sorted doesn't currently work and appears to never have actually worked. I put together this PR to address this issue.

The commit messages are well-written and thoroughly describe the changes that were made.

See issue #361.

Thanks!

Jason Franklin added 4 commits May 26, 2017 08:27
The trailing fold markers in "bookmark.vim" varied in how far they were
from the end of the line. This created an unpleasant visual effect when
folding was in use.
A more intention-revealing name was chosen for the script-local sorting
function. The function comment was also rewritten.
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 preservim#361 ("My bookmarks aren't sorted").
It makes the most sense to sort the global bookmarks list just before
rendering them in the NERDTree window. Since Vim's sort function is fast
and stable, and since users are very unlikely to have a number of
bookmarks that is too large, we can sort before rendering without
concern for the negligible performance penalty.

This has two benefits:
  1. Users can change their sort settings and have them take effect
     on the next render or refresh.
  2. As mentioned, code duplication is avoided.
@lifecrisis lifecrisis changed the title PRIORITY BUGFIX: Broken "g:NERDTreeBookmarksSort" setting fixed. BUGFIX: Broken "g:NERDTreeBookmarksSort" setting fixed. May 26, 2017
@PhilRunninger PhilRunninger merged commit c11affa into preservim:master May 26, 2017
@lifecrisis lifecrisis deleted the issue361 branch May 26, 2017 19:43
@lifecrisis
Copy link
Contributor Author

lifecrisis commented May 27, 2017

Thanks, @PhilRunninger, for the rapid response! 👍

Just letting you know that I've tested the behaviour of the sort on Vim 8.0 (Windows) and Vim 7.4 (Linux). It seems to work fine everywhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants