-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fix issues with sorting of nodes #856
Conversation
The cached _sortkey wasn't being recalculated after changing the NERDTreeSortOrder, resulting in incorrect sort orders.
The call to AddDefaultGroupToSortOrder in NERD_tree.vim is redundant because it's also done every time sortChildren is called. And since the check is done only once, there's no need for a function either. sortChildren now just contains the needed if statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks okay to me, functionality wise. However, the NERDTree is definitely slower with this change. I opened a large directory and benchmarked a root refresh for 100 iterations. With the new sorting code, it took 70.61s, compared to 55.09s without the cached sort key. Would you mind investigating to make this a tad faster? I can share my benchmarking tools if you need them.
Also add a new global variable to track when the g:NERDTreeSortOrder changes. If it has been changed, or when the cached _sortKey value is uninitialized, then calculate the sort key. This improves processing speed over the previous commit, and allows on-the-fly changes to the sort order, (without required vim to be restarted.)
@lifecrisis, Take a look at this now. I believe this will be sufficiently fast enough. The sort key will be recalculated only if it's uninitialized or when the g:NERDTreeSortOrder changes. Using your numbers above, your 100 root refreshes should take only |
This works! I'm no longer seeing the big slow-down I noticed before. I did only a perfunctory review of the changes to functionality, so I'm mainly just trusting you on that front. I don't make use of this feature myself. Thus, I haven't tested it much "in the field." Unless you have other qualms about this change, feel free to merge! |
This PR fixes two issues:
autoload/nerdtree.vim
)lib/nerdtree/path.vim
,lib/nerdtree/tree_dir_node.vim
, andplugin/NERD_tree.vim
)