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

Better way to handle multiple sort criteria? #444

Closed
wlh320 opened this issue Dec 4, 2024 · 1 comment · Fixed by #465
Closed

Better way to handle multiple sort criteria? #444

wlh320 opened this issue Dec 4, 2024 · 1 comment · Fixed by #465
Labels
feature New feature or request

Comments

@wlh320
Copy link

wlh320 commented Dec 4, 2024

Feature Description

Thank you for creating such a good plugin. I've been using it for two days, and I find it really fast.

I have some questions about the sorting of completion items. In current code, multiple sort criteria is implemented by a loop like this:

for sort in opts.sorts.iter() {
        match sort.as_str() {
            "kind" => matches.sort_by_key(...),
            "score" => matches.sort_by_cached_key(...),
            "label" => matches.sort_by(...),
        }
}

In my opinion, sometimes only the last criterion works, as each iteration of the loop may re-sort the entire list. For example, if a.label > b.label but a.kind < b.kind, what the expected output of sorting should be? Thank you!

@wlh320 wlh320 added the feature New feature or request label Dec 4, 2024
@Saghen Saghen mentioned this issue Dec 6, 2024
9 tasks
@Saghen Saghen closed this as completed in 7ff28da Dec 10, 2024
Saghen added a commit that referenced this issue Dec 10, 2024
Large rewrite of how sources are handled, adding support for async providers/timeouts, tree based fallbacks, dynamically adding sources and some other goodies

Closes #386
Closes #219
Closes #328
Closes #331
Closes #312
Closes #454
Closes #444
Closes #372
Closes #475
Saghen added a commit that referenced this issue Dec 11, 2024
Large rewrite of how sources are handled, adding support for async providers/timeouts, tree based fallbacks, dynamically adding sources and some other goodies

Closes #386
Closes #219
Closes #328
Closes #331
Closes #312
Closes #454
Closes #444
Closes #372
Closes #475
@wlh320
Copy link
Author

wlh320 commented Dec 11, 2024

Thank you very much!

In the default implementaion of label comparaion function in sort.lua, you seem to forget to compare label in the end.

function sort.label(a, b)

Saghen added a commit that referenced this issue Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant