Permalink
Browse files

Flush previous completions only for optionals. Need to think more abo…

…ut when to do the same for positionals.
  • Loading branch information...
1 parent 45ae8bf commit 32cead8f06cb29067a48f2ba74f9bbc8506e634a @kislyuk committed Mar 16, 2013
Showing with 6 additions and 4 deletions.
  1. +6 −4 argcomplete/__init__.py
View
@@ -225,10 +225,12 @@ def __call__(self, parser, namespace, values, option_string=None):
completer = completers.ChoicesCompleter(active_action.choices)
if completer:
- if not action_is_satisfied(active_action):
- # This means the current action will fail to parse if the word under the cursor is not given
- # to it, so give it exclusive control over completions (flush previous completions)
- completions = []
+ if len(active_action.option_strings) > 0: # only for optionals
+ if not action_is_satisfied(active_action):
+ # This means the current action will fail to parse if the word under the cursor is not given
+ # to it, so give it exclusive control over completions (flush previous completions)
+ debug("Resetting completions because", active_action, "is unsatisfied")
+ completions = []
try:
completions += [c for c in completer(prefix=cword_prefix,
parser=parser,

0 comments on commit 32cead8

Please sign in to comment.