summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/Utility/StringList.h8
-rw-r--r--lldb/source/Commands/CommandCompletions.cpp18
-rw-r--r--lldb/source/Utility/StringList.cpp23
3 files changed, 12 insertions, 37 deletions
diff --git a/lldb/include/lldb/Utility/StringList.h b/lldb/include/lldb/Utility/StringList.h
index 6d7474e4fc5..0b1d955678b 100644
--- a/lldb/include/lldb/Utility/StringList.h
+++ b/lldb/include/lldb/Utility/StringList.h
@@ -107,14 +107,6 @@ public:
// Copy assignment for a vector of strings
StringList &operator=(const std::vector<std::string> &rhs);
- // This string list contains a list of valid auto completion strings, and the
- // "s" is passed in. "matches" is filled in with zero or more string values
- // that start with "s", and the first string to exactly match one of the
- // string values in this collection, will have "exact_matches_idx" filled in
- // to match the index, or "exact_matches_idx" will have SIZE_MAX
- size_t AutoComplete(llvm::StringRef s, StringList &matches,
- size_t &exact_matches_idx) const;
-
// Dump the StringList to the given lldb_private::Log, `log`, one item per
// line. If given, `name` will be used to identify the start and end of the
// list in the output.
diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp
index 085531c5c07..9a969d289be 100644
--- a/lldb/source/Commands/CommandCompletions.cpp
+++ b/lldb/source/Commands/CommandCompletions.cpp
@@ -309,12 +309,18 @@ int CommandCompletions::SettingsNames(CommandInterpreter &interpreter,
}
}
- size_t exact_matches_idx = SIZE_MAX;
- StringList matches;
- g_property_names.AutoComplete(request.GetCursorArgumentPrefix(), matches,
- exact_matches_idx);
- request.SetWordComplete(exact_matches_idx != SIZE_MAX);
- request.AddCompletions(matches);
+ bool exact_match = false;
+
+ for (const std::string &s : g_property_names) {
+ if (llvm::StringRef(s).startswith(request.GetCursorArgumentPrefix())) {
+ if (request.GetCursorArgumentPrefix() == s)
+ exact_match = true;
+ request.AddCompletion(s);
+ }
+ }
+
+ request.SetWordComplete(exact_match);
+
return request.GetNumberOfMatches();
}
diff --git a/lldb/source/Utility/StringList.cpp b/lldb/source/Utility/StringList.cpp
index f570c3272f2..5e06b6b69fc 100644
--- a/lldb/source/Utility/StringList.cpp
+++ b/lldb/source/Utility/StringList.cpp
@@ -223,29 +223,6 @@ StringList &StringList::operator=(const std::vector<std::string> &rhs) {
return *this;
}
-size_t StringList::AutoComplete(llvm::StringRef s, StringList &matches,
- size_t &exact_idx) const {
- matches.Clear();
- exact_idx = SIZE_MAX;
- if (s.empty()) {
- // No string, so it matches everything
- matches = *this;
- return matches.GetSize();
- }
-
- const size_t s_len = s.size();
- const size_t num_strings = m_strings.size();
-
- for (size_t i = 0; i < num_strings; ++i) {
- if (m_strings[i].find(s) == 0) {
- if (exact_idx == SIZE_MAX && m_strings[i].size() == s_len)
- exact_idx = matches.GetSize();
- matches.AppendString(m_strings[i]);
- }
- }
- return matches.GetSize();
-}
-
void StringList::LogDump(Log *log, const char *name) {
if (!log)
return;
OpenPOWER on IntegriCloud