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

Order of completions #1733

Open
sigoden opened this issue Nov 24, 2023 · 1 comment
Open

Order of completions #1733

sigoden opened this issue Nov 24, 2023 · 1 comment

Comments

@sigoden
Copy link

sigoden commented Nov 24, 2023

Background

All mainstream shells allow users to control the order of completions.

  • Shells that have the option to control order

    • bash: complete -F _mycmd_completer -o nosort mycmd / -o nosort
    • fish: complete -x -k -c mycmd -a "(_mycmd_completer)" / -k
    • zsh: _describe "" displays values -Q -S '' -o nosort / -o nosort
  • Shells that preserve the order of the generated completions

    • powershell
    • nushell

It is necessary to follow this convention in Elvish.

Problem

Elvish doesn't provide an option to control the order of completions, but it automatically sorts completions. That's the problem.

Related issues: #525 #580 #915

Suggestion

Learn from PowerShell/Nushell, don't sort of the generated completions. For built-in completion lists such as filepath, when generating a list, ensure that it is already sorted.

If it is difficult to implement the above requirement due to compatibility or architecture, at least add a sort field to the candidate object.

edit:complex-candidate $stem1 &display='' &code-suffix='' &sort=0
edit:complex-candidate $stem2 &display='' &code-suffix='' &sort=1
@tw4452852
Copy link
Contributor

I also came across this issue today, my use case is that I want to show the most recently updated files at first when listing (e.g. ls <tab>), although I could achieve this by ls -tr but it would be more convenient if listing mode could support this by default.

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

No branches or pull requests

2 participants