File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -606,10 +606,14 @@ def command_case(prefix, options):
606606
607607 return f"""\
608608{ prefix } () {{
609- local context state line curcontext="$curcontext" one_or_more='(*)' remainder='(-)*'
609+ local context state line curcontext="$curcontext" one_or_more='(*)' remainder='(-)*' default='*::: :-> { name } '
610610
611- if ((${{{ prefix } _options[(I)${{(q)one_or_more}}*]}} + ${{{ prefix } _options[(I)${{(q)remainder}}*]}} == 0)); then # noqa: E501
612- { prefix } _options+=(': :{ prefix } _commands' '*::: :->{ name } ')
611+ # Add default positional/remainder specs only if none exist, and only once per session
612+ if (( ! { prefix } _defaults_added )); then
613+ if (( ${{{ prefix } _options[(I)${{(q)one_or_more}}*]}} + ${{{ prefix } _options[(I)${{(q)remainder}}*]}} + ${{{ prefix } _options[(I)${{(q)default}}]}} == 0 )); then
614+ { prefix } _options+=(': :{ prefix } _commands' '*::: :->{ name } ')
615+ fi
616+ { prefix } _defaults_added=1
613617 fi
614618 _arguments -C -s ${ prefix } _options
615619
@@ -631,6 +635,9 @@ def command_option(prefix, options):
631635{ prefix } _options=(
632636 { arguments }
633637)
638+
639+ # guard to ensure default positional specs are added only once per session
640+ { prefix } _defaults_added=0
634641"""
635642
636643 def command_list (prefix , options ):
You can’t perform that action at this time.
0 commit comments