elves / elvish

Powerful scripting language & versatile interactive shell
https://elv.sh/
BSD 2-Clause "Simplified" License
5.53k stars 297 forks source link

Order of completions #1733

Open sigoden opened 7 months ago

sigoden commented 7 months ago

Background

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

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 commented 5 months ago

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.