aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Interpreter/CommandInterpreter.cpp
diff options
context:
space:
mode:
authorShu Anzai <shu.anzai@gmail.com>2020-08-12 12:54:28 +0200
committerRaphael Isemann <teemperor@gmail.com>2020-08-12 13:11:20 +0200
commit246afe0cd17fce935a01171f3cca548e02523e5c (patch)
tree67be5d9034c8e63cea18cb67ac642b93913326f9 /lldb/source/Interpreter/CommandInterpreter.cpp
parent321aa19ec8ede62325b7e07d3fef4d12859275ab (diff)
downloadllvm-246afe0cd17fce935a01171f3cca548e02523e5c.zip
llvm-246afe0cd17fce935a01171f3cca548e02523e5c.tar.gz
llvm-246afe0cd17fce935a01171f3cca548e02523e5c.tar.bz2
[lldb] Display autosuggestion part in gray if there is one possible suggestion
I implemented autosuggestion if there is one possible suggestion. I set the keybinds for every character. When a character is typed, Editline::TypedCharacter is called. Then, autosuggestion part is displayed in gray, and you can actually input by typing C-k. Editline::Autosuggest is a function for finding completion, and it is like Editline::TabCommand now, but I will add more features to it. Testing does not work well in my environment, so I can't confirm that it goes well, sorry. I am dealing with it now. Reviewed By: teemperor, JDevlieghere, #lldb Differential Revision: https://reviews.llvm.org/D81001
Diffstat (limited to 'lldb/source/Interpreter/CommandInterpreter.cpp')
-rw-r--r--lldb/source/Interpreter/CommandInterpreter.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index 4786e46..ec82efb 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1878,6 +1878,19 @@ void CommandInterpreter::HandleCompletion(CompletionRequest &request) {
HandleCompletionMatches(request);
}
+llvm::Optional<std::string>
+CommandInterpreter::GetAutoSuggestionForCommand(llvm::StringRef line) {
+ if (line.empty())
+ return llvm::None;
+ const size_t s = m_command_history.GetSize();
+ for (int i = s - 1; i >= 0; --i) {
+ llvm::StringRef entry = m_command_history.GetStringAtIndex(i);
+ if (entry.consume_front(line))
+ return entry.str();
+ }
+ return llvm::None;
+}
+
CommandInterpreter::~CommandInterpreter() {}
void CommandInterpreter::UpdatePrompt(llvm::StringRef new_prompt) {