Skip to content

Commit

Permalink
fix zsh completion loaded from fpath (#2544)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidism authored Jun 30, 2023
2 parents 850bffe + aa4a38e commit df9ad40
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Unreleased
- Improve responsiveness of ``click.clear()``. :issue:`2284`
- Improve command name detection when using Shiv or PEX. :issue:`2332`
- Avoid showing empty lines if command help text is empty. :issue:`2368`
- ZSH completion script works when loaded from ``fpath``. :issue:`2344`.


Version 8.1.3
Expand Down
8 changes: 7 additions & 1 deletion src/click/shell_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,13 @@ def __getattr__(self, name: str) -> t.Any:
fi
}
compdef %(complete_func)s %(prog_name)s;
if [[ $zsh_eval_context[-1] == loadautofunc ]]; then
# autoload from fpath, call function directly
%(complete_func)s "$@"
else
# eval/source/. command, register function for later
compdef %(complete_func)s %(prog_name)s
fi
"""

_SOURCE_FISH = """\
Expand Down

0 comments on commit df9ad40

Please sign in to comment.