diff --git a/src/command_modules/azure-cli-interactive/HISTORY.rst b/src/command_modules/azure-cli-interactive/HISTORY.rst index 9f34244e3d2..ab20c79904f 100644 --- a/src/command_modules/azure-cli-interactive/HISTORY.rst +++ b/src/command_modules/azure-cli-interactive/HISTORY.rst @@ -3,6 +3,10 @@ Release History =============== +0.3.19 +++++++ +* Stops completions upon unrecognized commands. + 0.3.18 ++++++ * Completions kick in as soon as command table loading is done. diff --git a/src/command_modules/azure-cli-interactive/azure/cli/command_modules/interactive/azclishell/az_completer.py b/src/command_modules/azure-cli-interactive/azure/cli/command_modules/interactive/azclishell/az_completer.py index 82011b74f93..16bb2287798 100644 --- a/src/command_modules/azure-cli-interactive/azure/cli/command_modules/interactive/azclishell/az_completer.py +++ b/src/command_modules/azure-cli-interactive/azure/cli/command_modules/interactive/azclishell/az_completer.py @@ -240,7 +240,7 @@ def gen_cmd_and_param_completions(self): for param in self.command_param_info.get(self.current_command, []): if self.validate_param_completion(param, self.leftover_args): yield self.yield_param_completion(param, self.unfinished_word) - else: + elif not self.leftover_args: for child_command in self.subtree.children: if self.validate_completion(child_command): yield Completion(child_command, -len(self.unfinished_word)) diff --git a/src/command_modules/azure-cli-interactive/azure/cli/command_modules/interactive/tests/latest/test_completion.py b/src/command_modules/azure-cli-interactive/azure/cli/command_modules/interactive/tests/latest/test_completion.py index 38650d8b31b..0c4e3d4bb2b 100644 --- a/src/command_modules/azure-cli-interactive/azure/cli/command_modules/interactive/tests/latest/test_completion.py +++ b/src/command_modules/azure-cli-interactive/azure/cli/command_modules/interactive/tests/latest/test_completion.py @@ -36,10 +36,8 @@ def verify_completions(self, generated_completions, expected_completions, start_ def init_completer(self): with mock.patch.object(Configuration, 'get_help_files', lambda _: 'help_dump_test.json'): with mock.patch.object(Configuration, 'get_config_dir', lambda _: TEST_DIR): - print(TEST_DIR) shell_ctx = AzInteractiveShell(TestCli(), None) self.completer = shell_ctx.completer - print(self.completer.command_tree.children) def test_command_completion(self): # tests some azure commands @@ -75,6 +73,12 @@ def test_command_completion(self): completions = set(['vm', 'vmss']) self.verify_completions(gen, completions, -2) + # test unrecognized command does not complete + doc = Document(u'vm group ') + gen = self.completer.get_completions(doc, None) + completions = set() + self.verify_completions(gen, completions, 0) + def test_param_completion(self): # tests some azure params self.init_completer() diff --git a/src/command_modules/azure-cli-interactive/setup.py b/src/command_modules/azure-cli-interactive/setup.py index a24178464c4..9b41b565e64 100644 --- a/src/command_modules/azure-cli-interactive/setup.py +++ b/src/command_modules/azure-cli-interactive/setup.py @@ -14,7 +14,7 @@ cmdclass = {} # Version is also defined in azclishell.__init__.py. -VERSION = "0.3.18" +VERSION = "0.3.19" # The full list of classifiers is available at # https://pypi.python.org/pypi?%3Aaction=list_classifiers CLASSIFIERS = [