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: Don't complete _command on zsh #1690

Merged
merged 1 commit into from
Jun 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: Don't complete _command on zsh
Previously the generated zsh completion script started with the line

    #compdef _<command> <command>

where <command> is the command that the zsh completion script is
generated for.

This enabled completions for both <command> and _<command>, but
_<command> is the completion function itself and should not be
completed. Furthermore, attempting to autocomplete _<command> (e.g.
typing "_<command><Space><Tab>" in a zsh shell) causes zsh to hang.

This commit fixes the #compdef line to only complete <command>, not
_<command>.

Co-authored-by: Arvid Norlander <[email protected]>
  • Loading branch information
twpayne and VorpalBlade committed May 3, 2022
commit 29a8ff61b3cf48c99bd3db732424c71c5577dc5a
2 changes: 1 addition & 1 deletion zsh_completions.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func genZshComp(buf io.StringWriter, name string, includeDesc bool) {
if !includeDesc {
compCmd = ShellCompNoDescRequestCmd
}
WriteStringAndCheck(buf, fmt.Sprintf(`#compdef _%[1]s %[1]s
WriteStringAndCheck(buf, fmt.Sprintf(`#compdef %[1]s

# zsh completion for %-36[1]s -*- shell-script -*-

Expand Down