Skip to content

Commit 3faec83

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
1 parent b6f08b7 commit 3faec83

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
@@ -457,6 +457,10 @@ void REPL::IOHandlerComplete(IOHandler &io_handler,
457457
debugger.GetCommandInterpreter().HandleCompletion(sub_request);
458458
StringList matches, descriptions;
459459
sub_result.GetMatches(matches);
460+
// Prepend command prefix that was excluded in the completion request.
461+
if (request.GetCursorIndex() == 0)
462+
for (auto &match : matches)
463+
match.insert(0, 1, ':');
460464
sub_result.GetDescriptions(descriptions);
461465
request.AddCompletions(matches, descriptions);
462466
return;

0 commit comments

Comments
 (0)