Skip to content
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 completion scripts #1062

Merged
merged 1 commit into from
Feb 11, 2020
Merged

Fix zsh completion scripts #1062

merged 1 commit into from
Feb 11, 2020

Conversation

zhsj
Copy link
Contributor

@zhsj zhsj commented Feb 9, 2020

What type of PR is this?

(REQUIRED)

  • bug
  • cleanup
  • documentation
  • feature

What this PR does / why we need it:

(REQUIRED)

This fix completion when argument startswith -
And prevent completing a space when no candidates

Which issue(s) this PR fixes:

(REQUIRED)

Release Notes

(REQUIRED)

Fix zsh completion scripts

@zhsj zhsj requested a review from a team as a code owner February 9, 2020 17:35
@zhsj zhsj requested review from saschagrunert and rliebz and removed request for a team February 9, 2020 17:35
@codecov
Copy link

codecov bot commented Feb 9, 2020

Codecov Report

Merging #1062 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1062   +/-   ##
=======================================
  Coverage   72.83%   72.83%           
=======================================
  Files          33       33           
  Lines        2474     2474           
=======================================
  Hits         1802     1802           
  Misses        565      565           
  Partials      107      107

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7a5ed48...748fe05. Read the comment docs.

This fix completion when argument startswith -
And prevent completing a space when no candidates
@rliebz
Copy link
Member

rliebz commented Feb 11, 2020

Thanks for the fix!

Would you mind providing examples of what was broken before and what's changed? Between the PR description and the code changed, I'm having trouble understanding what exactly the issue was.

@zhsj
Copy link
Contributor Author

zhsj commented Feb 11, 2020

Thanks for fix!

Would you mind providing examples of what was broken before and what's changed? Between the PR description and the code changed, I'm having trouble understanding what exactly the issue was.

Before the change, if you type command -<tab> in zsh, nothing happens. With this change, it will display the candicates(eg -h).

The problem here is the words variable, when type <tab> before -, the last word is -, not "".

The change is based on the code of bash completion script,

if [[ "$cur" == "-"* ]]; then
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} ${cur} --generate-bash-completion )
else
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion )
fi

@rliebz rliebz merged commit d04c088 into urfave:master Feb 11, 2020
@zhsj zhsj deleted the fix-zsh branch February 11, 2020 11:42
zhsj added a commit to zhsj/containerd that referenced this pull request Feb 11, 2020
Fix completion when argument startswith `-`
Merged in upstream urfave/cli#1062

Signed-off-by: Shengjing Zhu <zhsj@debian.org>
@coilysiren coilysiren mentioned this pull request Mar 9, 2020
fahedouch pushed a commit to fahedouch/containerd that referenced this pull request Aug 7, 2020
Fix completion when argument startswith `-`
Merged in upstream urfave/cli#1062

Signed-off-by: Shengjing Zhu <zhsj@debian.org>
tussennet pushed a commit to tussennet/containerd that referenced this pull request Sep 11, 2020
Fix completion when argument startswith `-`
Merged in upstream urfave/cli#1062

Signed-off-by: Shengjing Zhu <zhsj@debian.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants