I'm writing completion function for zsh
. I took cargo
completion function as a basis for mine. For the most part it works fine except for -h
and --help
options. Completion ouput for these functions is unaligned and repeated multiple times (presented below). This only happens when control functions (_describe
, _arguments
etc) are present in case structure.
Why this is happening and how can I fix this behavior?
Completion function:
#compdef test
_test() {
local context state state_descr line
typeset -A opt_args
_arguments \
"(- 1 *)"{-h,--help}"[Help]" \
"1: :->command" \
"*:: :->args"
case $state in
command)
_alternative 'arguments:custom arg:(a b c)'
;;
args)
_arguments \
"-a[All]" \
"-n[None]"
esac
}
_test
Shell output:
> test -[TAB]
--help
-h
-- Help
--help
-h
-- Help
--help
-h
-- Help