Skip to content

Commit 3f0e7dd

Browse files
poyaTeemperor
authored andcommitted
[lldb] Fix missing characters when autocompleting LLDB commands in REPL
Summary: When tabbing to complete LLDB commands in REPL, characters would at best be missing but at worst cause the REPL to crash due to out of range string access. This patch appends the command character to the completion results to fulfill the assumption that all matches are prefixed by the request's cursor argument prefix. Bug report for the Swift REPL https://bugs.swift.org/browse/SR-12867 Reviewers: teemperor Reviewed By: teemperor Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D82835 (cherry picked from commit 3faec83)
1 parent ac83e27 commit 3f0e7dd

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lldb/source/Expression/REPL.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,10 @@ void REPL::IOHandlerComplete(IOHandler &io_handler,
452452
debugger.GetCommandInterpreter().HandleCompletion(sub_request);
453453
StringList matches, descriptions;
454454
sub_result.GetMatches(matches);
455+
// Prepend command prefix that was excluded in the completion request.
456+
if (request.GetCursorIndex() == 0)
457+
for (auto &match : matches)
458+
match.insert(0, 1, ':');
455459
sub_result.GetDescriptions(descriptions);
456460
request.AddCompletions(matches, descriptions);
457461
return;

0 commit comments

Comments
 (0)