o CommandObjectSettingsSet.cpp:
Fix a bug where "settings set -r th" wouldn't complete.
o UserSettingsController.cpp:
Fix a bug where "settings set target.process." wouldn't complete.
o test/functionalities/completion:
Add various completion test cases related to 'settings set' command.
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@148596 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Commands/CommandObjectSettings.cpp b/source/Commands/CommandObjectSettings.cpp
index 1a2ce9d..2a8b424 100644
--- a/source/Commands/CommandObjectSettings.cpp
+++ b/source/Commands/CommandObjectSettings.cpp
@@ -188,7 +188,11 @@
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 @@
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