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

Refactor sort comparison functions, removing redundancy #1166

Merged
merged 4 commits into from
Aug 14, 2020

Conversation

PhilRunninger
Copy link
Member

@PhilRunninger PhilRunninger commented Aug 14, 2020

Description of Changes

When researching #1162, I discovered a pair of functions that were doing very much the same thing: Path.compareTo(path) and nerdtree#compareNodesBySortKey(n1,n2). I removed the compareTo function, and used the more robust compareNodesBySortKey function instead.

Speaking of compareNodesBySortKey, there was another function named compareNodes that appeared to be unused. On the off chance that was written for other plugins, I decided to keep that function, refactored to fit the new structure.

I also added a new function to accept two path objects instead of node objects. It's named nerdtree#compareNodePaths, and to keep things simple, it is called by nerdtree#compareNodes.


New Version Info

Author's Instructions

  • Derive a new MAJOR.MINOR.PATCH version number. Increment the:
    • MAJOR version when you make incompatible API changes
    • MINOR version when you add functionality in a backwards-compatible manner
    • PATCH version when you make backwards-compatible bug fixes
  • Update CHANGELOG.md, following the established pattern.

Collaborator's Instructions

  • Review CHANGELOG.md, suggesting a different version number if necessary.
  • After merging, tag the commit using these (Mac-compatible) bash commands:
    git checkout master
    git pull
    sed -n "$(grep -n -m2 '####' CHANGELOG.md | cut -f1 -d: | sed 'N;s/\n/,/')p" CHANGELOG.md | sed '$d'
    git tag -a $(read -p "Tag Name: " tag;echo $tag) -m"$(git show --quiet --pretty=%s)";git push origin --tags

Use nerdtree#compareNodePaths(p1,p2) instead. There was no need for two
comparison functions that do the same thing. They were a little
different in their details, but that shouldn't be the case. Having only
one such function makes better sense and is easier to maintain.
@PhilRunninger PhilRunninger merged commit 23000ac into master Aug 14, 2020
@PhilRunninger PhilRunninger deleted the refactor_sorting branch August 14, 2020 22:06
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.

1 participant