File tree 1 file changed +30
-1
lines changed
1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -138,13 +138,42 @@ __%[1]s_process_completion_results() {
138
138
_filedir -d
139
139
fi
140
140
else
141
- __%[1]s_handle_standard_completion_case
141
+ __%[1]s_handle_completion_types
142
142
fi
143
143
144
144
__%[1]s_handle_special_char "$cur" :
145
145
__%[1]s_handle_special_char "$cur" =
146
146
}
147
147
148
+ __%[1]s_handle_completion_types() {
149
+ __%[1]s_debug "__%[1]s_handle_completion_types: COMP_TYPE is $COMP_TYPE"
150
+
151
+ case $COMP_TYPE in
152
+ 37|42)
153
+ # Type: menu-complete/menu-complete-backward and insert-completions
154
+ # If the user requested inserting one completion at a time, or all
155
+ # completions at once on the command-line we must remove the descriptions.
156
+ # https://github.com/spf13/cobra/issues/1508
157
+ local tab comp
158
+ tab=$(printf '\t')
159
+ while IFS='' read -r comp; do
160
+ # Strip any description
161
+ comp=${comp%%%%$tab*}
162
+ # Only consider the completions that match
163
+ comp=$(compgen -W "$comp" -- "$cur")
164
+ if [ -n "$comp" ]; then
165
+ COMPREPLY+=("$comp")
166
+ fi
167
+ done < <(printf "%%s\n" "${out[@]}")
168
+ ;;
169
+
170
+ *)
171
+ # Type: complete (normal completion)
172
+ __%[1]s_handle_standard_completion_case
173
+ ;;
174
+ esac
175
+ }
176
+
148
177
__%[1]s_handle_standard_completion_case() {
149
178
local tab comp
150
179
tab=$(printf '\t')
You can’t perform that action at this time.
0 commit comments