Permalink
Browse files

Reset completions when subparsers are activated. Fixes #15

  • Loading branch information...
1 parent d1f5474 commit 7bd25c31a7a46804618909225ed0a7412a729845 @kislyuk committed Mar 6, 2013
Showing with 4 additions and 1 deletion.
  1. +4 −1 argcomplete/__init__.py
View
@@ -179,7 +179,10 @@ def __call__(self, parser, namespace, values, option_string=None):
for subparser in action._name_parser_map.values():
if subparser in active_parsers:
subparser_activated = True
- if not subparser_activated:
+ if subparser_activated:
+ # Parent parser completions are not valid in the subparser, so flush them
+ completions = []
+ else:
completions += [subcmd for subcmd in action.choices.keys() if subcmd.startswith(cword_prefix)]
elif always_complete_options or (len(cword_prefix) > 0 and cword_prefix[0] in parser.prefix_chars):
completions += [option for option in action.option_strings if option.startswith(cword_prefix)]

0 comments on commit 7bd25c3

Please sign in to comment.