-
Notifications
You must be signed in to change notification settings - Fork 2.9k
preserve ordering of completions passed to zsh autocomplete #1900
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
Comments
Thanks for the report @h4ck3rk3y . I think this is tricky because even with the -v things will be dependent on the order the program returns the completions. I guess that for this option to make sense the program would consciously order the list of completions and specify to preserve the order? We'd also have to look at how this case applies to the other three shells. But I'm open to the idea. |
Yep thats the idea, the person using the library would use a flag to preserve order and then send their ordered list. Agree, we'll have to figure out how this applies to |
Bash requires the the Lines 354 to 358 in badcce1
-o nosort here works.
Fish has a Seems like power shell keeps the order by default even with the current code base |
Sounds like a nice addition. I'm looking forward to your contribution. |
I went through the Cobra code a little more and I am thinking of doing it in the following way
This allows some granular control per validation function and if a user wants to start using it they just set the directive. Let me know if this makes sense! |
Brilliant! That sounds perfect. |
+1 for this, just stumbled onto the same issue and came to the same findings about adding Would love to provide any assistance if any help is needed support this! |
i have created a pr using the directive logic i mentioned above, is there a good example to test behavior of generated scripts against passed directives? i have tested the changes by using generations for our own binary against situations where we want to preserve out put and where we don't |
cobra/zsh_completions.go
Line 265 in 6d978a9
The way describes works with the following input -
apple cat bat
, it would sort it for you, and suggestapple bat cat
. If we pass the-V
flag we end up preserving the ordering of the passed completion,a real world example,
on pressing tab you get, dry-thunder edf1abc0bfc445b38d46a82585a8bfd0 edf78299bbbd453f9552a3b730d68834 edffa85eb3b14e22951f47e252c5fbbf patient-field twilight-shadow
if we change the above line to
if eval _describe -V "completions" completions $flagPrefix $noSpace; then
we maintain the passed ordering. Would you be open to a contribution that gives users an option to preserve ordering?
The text was updated successfully, but these errors were encountered: