aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Interpreter/CommandInterpreter.cpp
diff options
context:
space:
mode:
authorDavid Spickett <david.spickett@linaro.org>2023-09-13 10:12:12 +0100
committerGitHub <noreply@github.com>2023-09-13 10:12:12 +0100
commit461f859a722fb80103d437005bb14deb215f8260 (patch)
tree5be0c1a447270cc4397ea7191d8021d922a8cc10 /lldb/source/Interpreter/CommandInterpreter.cpp
parent99594ba30aaba7ad7c0850923bac474e4676af8e (diff)
downloadllvm-461f859a722fb80103d437005bb14deb215f8260.zip
llvm-461f859a722fb80103d437005bb14deb215f8260.tar.gz
llvm-461f859a722fb80103d437005bb14deb215f8260.tar.bz2
[lldb] Treat user aliases the same as built-ins when tab completing (#65974)
Previously we would check all built-ins first for suggestions, then check built-ins and aliases. This meant that if you had an alias brkpt -> breakpoint, "br" would complete to "breakpoint". Instead of giving you the choice of "brkpt" or "breakpoint".
Diffstat (limited to 'lldb/source/Interpreter/CommandInterpreter.cpp')
-rw-r--r--lldb/source/Interpreter/CommandInterpreter.cpp40
1 files changed, 10 insertions, 30 deletions
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index 6d1ad799..dcff53f 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -508,6 +508,11 @@ void CommandInterpreter::Initialize() {
if (cmd_obj_sp) {
AddAlias("history", cmd_obj_sp);
}
+
+ cmd_obj_sp = GetCommandSPExact("help");
+ if (cmd_obj_sp) {
+ AddAlias("h", cmd_obj_sp);
+ }
}
void CommandInterpreter::Clear() {
@@ -1227,36 +1232,11 @@ CommandObject *
CommandInterpreter::GetCommandObject(llvm::StringRef cmd_str,
StringList *matches,
StringList *descriptions) const {
- CommandObject *command_obj =
- GetCommandSP(cmd_str, false, true, matches, descriptions).get();
-
- // If we didn't find an exact match to the command string in the commands,
- // look in the aliases.
-
- if (command_obj)
- return command_obj;
-
- command_obj = GetCommandSP(cmd_str, true, true, matches, descriptions).get();
-
- if (command_obj)
- return command_obj;
-
- // If there wasn't an exact match then look for an inexact one in just the
- // commands
- command_obj = GetCommandSP(cmd_str, false, false, nullptr).get();
-
- // Finally, if there wasn't an inexact match among the commands, look for an
- // inexact match in both the commands and aliases.
-
- if (command_obj) {
- if (matches)
- matches->AppendString(command_obj->GetCommandName());
- if (descriptions)
- descriptions->AppendString(command_obj->GetHelp());
- return command_obj;
- }
-
- return GetCommandSP(cmd_str, true, false, matches, descriptions).get();
+ // Try to find a match among commands and aliases. Allowing inexact matches,
+ // but perferring exact matches.
+ return GetCommandSP(cmd_str, /*include_aliases=*/true, /*exact=*/false,
+ matches, descriptions)
+ .get();
}
CommandObject *CommandInterpreter::GetUserCommandObject(