-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Fish completion does not handle "nospace" or file completion properly #1248
Comments
This issue is being marked as stale due to a long period of inactivity |
PR #1249 awaiting review. |
marckhouzam
added a commit
to VilledeMontreal/helm
that referenced
this issue
Feb 27, 2021
Ref: HIP 0008 When completing a repo name, extra information will be shown for shells that support completions (fish, zsh). For example: $ helm repo remove <TAB> bitnami -- https://charts.bitnami.com/bitnami center -- https://repo.chartcenter.io stable -- https://kubernetes-charts.storage.googleapis.com This commit does not add the description to repo names for the commands: intall, template, upgrade, show and pull. This is because we first need a couple of Cobra fixes: spf13/cobra#1211 spf13/cobra#1248 Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is the same bug that is present for
zsh
and described in #1211 and #1212.Bug 1: File completion is not respected
The
fish
completion script performs file completion only if it receives no completions:cobra/fish_completions.go
Line 151 in b97b5ea
However, it is valid for
ValidArgsFunction
to return completions that don't apply to the currenttoComplete
prefix. This means file completion should be performed, but the script does not realize it as it still believes it received valid completions.Say I have the following
ValidArgsFunction
for commandwithfile
:If I have a file called
myfile
and run infish
:I would expect to get file completion and get
myfile
as a completion, but I don't. This is becauseNotice that above, the script would receive a completion even though it is not technically valid. This is allowed. But then, the script does not realize it must do file completion.
Bug 2: NoSpace is not respected all the time
For the exact same reason,
ShellCompDirectiveNoSpace
also fails when the__complete
command returns completions that don't match thetoComplete
prefix.Say I have the following
ValidArgsFunction
for commandnospace
:If I run in
fish
:a space is added after
./testprog nospace when
even though theShellCompDirectiveNoSpace
was given.This is because the script only handles
ShellCompDirectiveNoSpace
if a single completion is returned:cobra/fish_completions.go
Line 144 in b97b5ea
But my
ValidArgsFunction
does not filter the completions but instead returns all of them, leavingfish
to filter them. In this case:Notice that with the result above the completion script would receive two completions even though the
who
completion is not technically valid. This is allowed.Bug 3: NoSpace not respected with descriptions
Finally, the nospace logic for fish does not handle the case when there is a description. To achieve "nospace" the script adds a second completion with an extra "." to prevent the shell from adding a space. However if there is a description, the extra "." is added to the description instead of the completion, and the nospace directive does not work.
I will post a PR to handle this better.
The text was updated successfully, but these errors were encountered: