diff options
Diffstat (limited to 'lldb/source')
-rw-r--r-- | lldb/source/Commands/CommandObjectSettings.cpp | 10 | ||||
-rw-r--r-- | lldb/source/Core/UserSettingsController.cpp | 28 |
2 files changed, 24 insertions, 14 deletions
diff --git a/lldb/source/Commands/CommandObjectSettings.cpp b/lldb/source/Commands/CommandObjectSettings.cpp index 1a2ce9d835f..2a8b4247275 100644 --- a/lldb/source/Commands/CommandObjectSettings.cpp +++ b/lldb/source/Commands/CommandObjectSettings.cpp @@ -188,7 +188,11 @@ CommandObjectSettingsSet::HandleArgumentCompletion (Args &input, completion_str.erase (cursor_char_position); // Attempting to complete variable name - if (cursor_index == 1) + llvm::StringRef prev_str(cursor_index == 2 ? input.GetArgumentAtIndex(1) : ""); + if (cursor_index == 1 || + (cursor_index == 2 && prev_str.startswith("-")) // "settings set -r th", followed by Tab. + ) + { CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, CommandCompletions::eSettingsNameCompletion, completion_str.c_str(), @@ -197,6 +201,10 @@ CommandObjectSettingsSet::HandleArgumentCompletion (Args &input, NULL, word_complete, matches); + // If there is only 1 match which fulfills the completion request, do an early return. + if (matches.GetSize() == 1 && completion_str.compare(matches.GetStringAtIndex(0)) != 0) + return 1; + } // Attempting to complete value if ((cursor_index == 2) // Partly into the variable's value diff --git a/lldb/source/Core/UserSettingsController.cpp b/lldb/source/Core/UserSettingsController.cpp index 65c263f396e..de3a71dd59e 100644 --- a/lldb/source/Core/UserSettingsController.cpp +++ b/lldb/source/Core/UserSettingsController.cpp @@ -1714,19 +1714,21 @@ UserSettingsController::CompleteSettingsNames (const UserSettingsControllerSP& u } + // The variable my_usc_sp keeps track of the user settings controller as + // we descend through the tree hierarchy. + UserSettingsControllerSP my_usc_sp = usc_sp; for (int i = 0; i < num_extra_levels; ++i) { ConstString child_level (partial_setting_name_pieces.GetArgumentAtIndex (0)); bool found = false; - int num_children = usc_sp->GetNumChildren(); - UserSettingsControllerSP child_usc_sp = usc_sp; + int num_children = my_usc_sp->GetNumChildren(); for (int j = 0; j < num_children && !found; ++j) { - if (child_usc_sp->GetChildAtIndex (j)->GetLevelName() == child_level) + if (my_usc_sp->GetChildAtIndex (j)->GetLevelName() == child_level) { found = true; - child_usc_sp = child_usc_sp->GetChildAtIndex (j); + my_usc_sp = my_usc_sp->GetChildAtIndex (j); partial_setting_name_pieces.Shift(); } } @@ -1750,15 +1752,15 @@ UserSettingsController::CompleteSettingsNames (const UserSettingsControllerSP& u // 'next_name' is an instance name. The last name piece must be a non-empty partial match against an // instance_name, assuming 'next_name' is valid. - if (usc_sp->IsLiveInstance (next_name)) + if (my_usc_sp->IsLiveInstance (next_name)) { std::string complete_prefix; - usc_sp->BuildParentPrefix (complete_prefix); + my_usc_sp->BuildParentPrefix (complete_prefix); - num_matches = usc_sp->InstanceVariableMatches(partial_setting_name_pieces.GetArgumentAtIndex(0), - complete_prefix, - next_name.c_str(), - matches); + num_matches = my_usc_sp->InstanceVariableMatches(partial_setting_name_pieces.GetArgumentAtIndex(0), + complete_prefix, + next_name.c_str(), + matches); word_complete = true; if (num_matches > 1) word_complete = false; @@ -1772,14 +1774,14 @@ UserSettingsController::CompleteSettingsNames (const UserSettingsControllerSP& u { // 'next_name' must be a child name. Find the correct child and pass the remaining piece to be resolved. bool found = false; - int num_children = usc_sp->GetNumChildren(); + int num_children = my_usc_sp->GetNumChildren(); ConstString child_level (next_name.c_str()); for (int i = 0; i < num_children; ++i) { - if (usc_sp->GetChildAtIndex (i)->GetLevelName() == child_level) + if (my_usc_sp->GetChildAtIndex (i)->GetLevelName() == child_level) { found = true; - return UserSettingsController::CompleteSettingsNames (usc_sp->GetChildAtIndex (i), + return UserSettingsController::CompleteSettingsNames (my_usc_sp->GetChildAtIndex (i), partial_setting_name_pieces, word_complete, matches); } |