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

Sort completions #923

Closed
ghost opened this issue Jul 21, 2013 · 6 comments
Closed

Sort completions #923

ghost opened this issue Jul 21, 2013 · 6 comments
Labels
bug Something that's not working as intended
Milestone

Comments

@ghost
Copy link

ghost commented Jul 21, 2013

Current sorting (none):

$ systemd-<tab>
systemd-cat                     (Executable, 26kB)
systemd-cgls                    (Executable, 46kB)
systemd-cgtop                   (Executable, 54kB)
systemd-delta                   (Executable, 38kB)
systemd-notify                  (Executable, 30kB)
systemd-nspawn                  (Executable, 90kB)
systemd-analyze                 (Executable, 62kB)
systemd-inhibit                 (Executable, 38kB)
systemd-tmpfiles                (Executable, 62kB)
systemd-coredumpctl             (Executable, 42kB)
systemd-detect-virt             (Executable, 30kB)
systemd-ask-password            (Executable, 38kB)
systemd-stdio-bridge           (Executable, 110kB)
systemd-machine-id-setup        (Executable, 34kB)
systemd-tty-ask-password-agent  (Executable, 58kB)

Probably would be helpful to sort them, although, this can potentially cause performance problems for large lists.

@zanchey
Copy link
Member

zanchey commented Jul 23, 2013

They are sorted - just not in the way you might expect! They are sorted on length then on alphabetical ordering.

I think this is a bug.

@zanchey
Copy link
Member

zanchey commented Jul 23, 2013

Ah, sorting is done with wcscmp and our own wcsfilecmp, where longer strings are greater than shorter strings.

@ghost
Copy link
Author

ghost commented Jul 23, 2013

...I did not notice this. I think that it's because the shorter strings are more likely to fuzzy-match, whereas in this case, it's probably better to have them just be sorted alphabetically if it's a prefix match.

@ridiculousfish
Copy link
Member

The list is sorted by length.

The issue here is in determining the distance ("goodness") of a match. For a fuzzy match, i.e.: iff<tab> we should obviously prefer diff to tiffdither. In most cases, shorter matches are better because a larger percentage of characters are matched, so the list is effectively sorted by length.

Are there circumstances where this is not so? Maybe for prefix matches?

@ridiculousfish
Copy link
Member

Let's try sorting prefix match strings alphabetically, and fuzzy match strings by length, and see how weird that is.

@ridiculousfish
Copy link
Member

Implemented here: c38a40d . let's see how this feels.

Thanks for reporting this!

haarts pushed a commit to haarts/fish-shell that referenced this issue Nov 1, 2013
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something that's not working as intended
Projects
None yet
Development

No branches or pull requests

2 participants