elves / elvish

Powerful scripting language & versatile interactive shell

Home Page:https://elv.sh/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Order of completions

sigoden opened this issue · comments

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
commented

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.