@@ -193,7 +193,7 @@ def flag_based_complete(text, line, begidx, endidx, flag_dict, default_completer
193193 return []
194194
195195 completions = []
196- flag_processed = False
196+ flag_present = False
197197
198198 # Must have at least the command and one argument for a flag to be present
199199 if len (tokens ) > 1 :
@@ -204,9 +204,10 @@ def flag_based_complete(text, line, begidx, endidx, flag_dict, default_completer
204204 # Check if the flag is in the dictionary
205205 if flag in flag_dict :
206206
207+ flag_present = True
208+
207209 # Check if this flag does completions using an Iterable
208210 if isinstance (flag_dict [flag ], collections .Iterable ):
209- flag_processed = True
210211 strs_to_match = flag_dict [flag ]
211212 completions = [cur_str for cur_str in strs_to_match if cur_str .startswith (text )]
212213
@@ -216,12 +217,11 @@ def flag_based_complete(text, line, begidx, endidx, flag_dict, default_completer
216217
217218 # Otherwise check if this flag does completions with a function
218219 elif callable (flag_dict [flag ]):
219- flag_processed = True
220220 completer_func = flag_dict [flag ]
221221 completions = completer_func (text , line , begidx , endidx )
222222
223223 # Check if we need to run the default completer
224- if default_completer is not None and not flag_processed :
224+ if default_completer is not None and not flag_present :
225225 completions = default_completer (text , line , begidx , endidx )
226226
227227 completions .sort ()
0 commit comments