File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -126,6 +126,26 @@ _comp_compgen__call_builtin() {
126126 esac
127127 done
128128
129+ # Also check if -W option is used with ${files[@]} or similar array expansion
130+ # which is a common pattern for file completion
131+ if [[ " $is_file_completion " == false ]]; then
132+ local i=0
133+ while [[ $i -lt ${# compgen_args[@]} ]]; do
134+ if [[ " ${compgen_args[$i]} " == " -W" ]]; then
135+ local next_idx=$(( i + 1 ))
136+ if [[ $next_idx -lt ${# compgen_args[@]} ]]; then
137+ local word_arg=" ${compgen_args[$next_idx]} "
138+ # Check if it contains ${files or similar array patterns
139+ if [[ " $word_arg " == * ' ${files' * ]] || [[ " $word_arg " == * ' ${toks' * ]] || [[ " $word_arg " == * ' $files' * ]] || [[ " $word_arg " == * ' $toks' * ]]; then
140+ is_file_completion=true
141+ break
142+ fi
143+ fi
144+ fi
145+ (( i++ ))
146+ done
147+ fi
148+
129149 # If this looks like file completion, add pinyin matches
130150 if [[ " $is_file_completion " == true ]]; then
131151 _add_completion " $@ "
You can’t perform that action at this time.
0 commit comments