diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp b/lldb/source/Commands/CommandObjectMultiword.cpp --- a/lldb/source/Commands/CommandObjectMultiword.cpp +++ b/lldb/source/Commands/CommandObjectMultiword.cpp @@ -274,10 +274,10 @@ StringList new_matches; CommandObject *sub_command_object = GetSubcommandObject(arg0, &new_matches); - if (sub_command_object == nullptr) { - request.AddCompletions(new_matches); + + // The subcommand is ambiguous. The completion isn't meaningful. + if (!sub_command_object) return; - } // Remove the one match that we got from calling GetSubcommandObject. new_matches.DeleteStringAtIndex(0); diff --git a/lldb/test/API/functionalities/completion/TestCompletion.py b/lldb/test/API/functionalities/completion/TestCompletion.py --- a/lldb/test/API/functionalities/completion/TestCompletion.py +++ b/lldb/test/API/functionalities/completion/TestCompletion.py @@ -880,3 +880,11 @@ self.complete_from_to("breakpoint set -N n", "breakpoint set -N n") self.assertTrue(bp1.AddNameWithErrorHandling("nn")) self.complete_from_to("breakpoint set -N ", "breakpoint set -N nn") + + def test_ambiguous_command(self): + """Test completing an ambiguous commands""" + self.complete_from_to("settings s", ['set', 'show']) + + def test_ambiguous_subcommand(self): + """Test completing a subcommand of an ambiguous command""" + self.complete_from_to("settings s ta", [])