-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
fix(zsh): Use _default as the completion fallback where the ValueHint is Unknown #5791
Conversation
That is for a ValueHint of Unknown. This is consistent with bash where compgen -f is used in such cases. In long experience with completions distributed with zsh, the worst thing you can do is break filename completion as that's the minimum most user's expect.
e6de840
to
13adae1
Compare
Thanks!
btw have you seen our new completion system which moves most of the runtime logic to Rust (#3166)? We got descriptions working in #5775 and the author of that has an idea on how to fix #5752. If you have any zsh-specific insights for how to improve it further more generally or for mimicking any of the carapace features (#5651, #5650, #5649), that would be great! I only use bash, am not a heavy completion user, and find the documentation for these things only focused on general hand maintained completions, making it difficult for me to help improve some of the shell integration. |
Looks like you need to run $ SNAPSHOTS=overwrite cargo test -p clap_complete -F unstable-shell-tests |
So if I understand, this is taking the approach of running something like: COMPREPLY=( And doing all the logic in Rust code. This approach can be tempting when you consider only bash's rather limited interface for completion but it ends up dumbing down the functionality of any other shell to the level of bash. Allowing As to #5752, the short answer, is to use the |
That fails for me on current master with |
13adae1
to
e40168c
Compare
Something to that effect. The plan is to deprecate the existing completions in Our issue tracking this is #3166 and the issue specifically for parity in zsh with the existing completions is #3916. If you are concerned about this plan, I would recommend opening issues about the missing features and incorrect behavior so we have a more concrete idea to go off of than high level concerns. This is coming about because we've found the existing approach of generating (or hand maintaining) completions for each shell isn't scalable. It requires expertise in a shell to implement or review, it is hard to test, we've had a plethora of issues building up in supporting each shell, we've had a wide disparity in offered features for each shell because implementers aren't generally skilled in every shell, etc. So far, we've only needed minimal shims in the shell language and Rust for each shell while we're able to offer a smarter set of completions that is tailored to the extra information clap has that the shells do not. We're not the only ones doing this as there are cases of CLI parsers doing this in Rust, Python, Go, etc. |
This is consistent with bash where
compgen -f
is used in such cases. In long experience with completions distributed with zsh, the worst thing you can do is break filename completion as that's the minimum most user's expect. By default, _default just completes files. It is also far better to leave the final component blank fromValueHint::Other
as using empty parentheses will cause zsh to do slightly more work for the same result.For context, note that I'm a zsh developer and have a lot of experience of writing zsh completions manually.