@@ -67,11 +67,10 @@ __gitcomp_opts ()
[[ "$cur_" == *= ]] && return
local c IFS=$' \t\n' sfx
- local -a array
for c in ${=1}; do
if [[ $c == "--" ]]; then
[[ "$cur_" == --no-* ]] && continue
- array+=("--no-... ")
+ compadd -S " " -- "--no-..." && _ret=0
break
fi
@@ -83,9 +82,8 @@ __gitcomp_opts ()
else
sfx="$4"
fi
- array+=("$c$sfx")
+ compadd -S "$sfx" -p "${2-}" -- "$c" && _ret=0
done
- compadd -S '' -p "${2-}" -a -- array && _ret=0
}
__gitcomp_nl ()
@@ -124,7 +124,7 @@ test_expect_success '__gitcomp_opts - option parameter' '
EOF
'
-test_expect_failure '__gitcomp_opts - prefix' '
+test_expect_success '__gitcomp_opts - prefix' '
test_gitcomp_opts "branch.maint.me" "remote merge mergeoptions rebase" \
"branch.maint." "me" <<-\EOF
branch.maint.merge Z
@@ -132,7 +132,7 @@ test_expect_failure '__gitcomp_opts - prefix' '
EOF
'
-test_expect_failure '__gitcomp_opts - suffix' '
+test_expect_success '__gitcomp_opts - suffix' '
test_gitcomp_opts "branch.ma" "master maint next seen" "branch." \
"ma" "." <<-\EOF
branch.master.Z
It's useful to specify specific suffixes for specific words. This will be useful later on. Additionally two tests now pass because we are not using an array anymore. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> --- contrib/completion/git-completion.zsh | 6 ++---- t/t9904-completion-zsh.sh | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-)