[PATCH 43/51] completion: zsh: add __gitcompadd helper
From: Felipe Contreras <hidden>
Date: 2022-08-30 09:35:02
Subsystem:
the rest · Maintainer:
Linus Torvalds
From: Felipe Contreras <hidden>
Date: 2022-08-30 09:35:02
Subsystem:
the rest · Maintainer:
Linus Torvalds
So we don't have to do the same over and over. Signed-off-by: Felipe Contreras <redacted> --- contrib/completion/git-completion.zsh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 42bf9b95eb..e66044ee89 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh@@ -50,12 +50,16 @@ COMP_WORDBREAKS=':' GIT_SOURCING_ZSH_COMPLETION=y . "$script" functions[complete]="$old_complete" +__gitcompadd () +{ + compadd -p "${2-}" -S "${3- }" -- ${=1} && _ret=0 +} + __gitcomp () { emulate -L zsh - local IFS=$' \t\n' - compadd -S "${4- }" -p "${2-}" -- ${=1} && _ret=0 + IFS=$' \t\n' __gitcompadd "$1" "${2-}" "${4- }" } __gitcomp_opts ()
@@ -70,7 +74,7 @@ __gitcomp_opts () for c in ${=1}; do if [[ $c == "--" ]]; then [[ "$cur_" == --no-* ]] && continue - compadd -S " " -- "--no-..." && _ret=0 + __gitcompadd "--no-..." break fi
@@ -82,7 +86,7 @@ __gitcomp_opts () else sfx="$4" fi - compadd -S "$sfx" -p "${2-}" -- "$c" && _ret=0 + __gitcompadd "$c" "${2-}" "$sfx" done }
--
2.37.2.351.g9bf691b78c.dirty