summaryrefslogtreecommitdiff
path: root/source/Commands/CommandObjectMultiword.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2018-08-02 17:33:54 +0000
committerDimitry Andric <dim@FreeBSD.org>2018-08-02 17:33:54 +0000
commit39be7ce23363d12ae3e49aeb1fdb2bfeb892e836 (patch)
tree37fd694b2fe544b0ccefb369794632592d138dde /source/Commands/CommandObjectMultiword.cpp
parentf73363f1dd94996356cefbf24388f561891acf0b (diff)
Notes
Diffstat (limited to 'source/Commands/CommandObjectMultiword.cpp')
-rw-r--r--source/Commands/CommandObjectMultiword.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/source/Commands/CommandObjectMultiword.cpp b/source/Commands/CommandObjectMultiword.cpp
index ade1a2d01f382..19fcf60e557cb 100644
--- a/source/Commands/CommandObjectMultiword.cpp
+++ b/source/Commands/CommandObjectMultiword.cpp
@@ -143,7 +143,7 @@ bool CommandObjectMultiword::Execute(const char *args_string,
if (num_subcmd_matches > 0) {
error_msg.append(" Possible completions:");
- for (size_t i = 0; i < num_subcmd_matches; i++) {
+ for (size_t i = 0; i < matches.GetSize(); i++) {
error_msg.append("\n\t");
error_msg.append(matches.GetStringAtIndex(i));
}
@@ -190,21 +190,22 @@ int CommandObjectMultiword::HandleCompletion(CompletionRequest &request) {
// Any of the command matches will provide a complete word, otherwise the
// individual completers will override this.
request.SetWordComplete(true);
- auto &matches = request.GetMatches();
auto arg0 = request.GetParsedLine()[0].ref;
if (request.GetCursorIndex() == 0) {
- AddNamesMatchingPartialString(m_subcommand_dict, arg0, matches);
+ StringList new_matches;
+ AddNamesMatchingPartialString(m_subcommand_dict, arg0, new_matches);
+ request.AddCompletions(new_matches);
- if (matches.GetSize() == 1 && matches.GetStringAtIndex(0) != nullptr &&
- (arg0 == matches.GetStringAtIndex(0))) {
+ if (new_matches.GetSize() == 1 &&
+ new_matches.GetStringAtIndex(0) != nullptr &&
+ (arg0 == new_matches.GetStringAtIndex(0))) {
StringList temp_matches;
CommandObject *cmd_obj = GetSubcommandObject(arg0, &temp_matches);
if (cmd_obj != nullptr) {
if (request.GetParsedLine().GetArgumentCount() == 1) {
request.SetWordComplete(true);
} else {
- matches.DeleteStringAtIndex(0);
request.GetParsedLine().Shift();
request.SetCursorCharPosition(0);
request.GetParsedLine().AppendArgument(llvm::StringRef());
@@ -212,14 +213,17 @@ int CommandObjectMultiword::HandleCompletion(CompletionRequest &request) {
}
}
}
- return matches.GetSize();
+ return new_matches.GetSize();
} else {
- CommandObject *sub_command_object = GetSubcommandObject(arg0, &matches);
+ StringList new_matches;
+ CommandObject *sub_command_object = GetSubcommandObject(arg0, &new_matches);
if (sub_command_object == nullptr) {
- return matches.GetSize();
+ request.AddCompletions(new_matches);
+ return request.GetNumberOfMatches();
} else {
// Remove the one match that we got from calling GetSubcommandObject.
- matches.DeleteStringAtIndex(0);
+ new_matches.DeleteStringAtIndex(0);
+ request.AddCompletions(new_matches);
request.GetParsedLine().Shift();
request.SetCursorIndex(request.GetCursorIndex() - 1);
return sub_command_object->HandleCompletion(request);
@@ -366,7 +370,6 @@ int CommandObjectProxy::HandleCompletion(CompletionRequest &request) {
CommandObject *proxy_command = GetProxyCommandObject();
if (proxy_command)
return proxy_command->HandleCompletion(request);
- request.GetMatches().Clear();
return 0;
}
@@ -375,7 +378,6 @@ int CommandObjectProxy::HandleArgumentCompletion(
CommandObject *proxy_command = GetProxyCommandObject();
if (proxy_command)
return proxy_command->HandleArgumentCompletion(request, opt_element_vector);
- request.GetMatches().Clear();
return 0;
}