[Lldb-commits] [lldb] 3faec83 - [lldb] Fix missing characters when autocompleting LLDB commands in REPL

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Fri Jul 3 03:10:25 PDT 2020


Author: Martin Svensson
Date: 2020-07-03T12:10:00+02:00
New Revision: 3faec833760fa7ab6e3180378da8c8fb4abbdb11

URL: https://github.com/llvm/llvm-project/commit/3faec833760fa7ab6e3180378da8c8fb4abbdb11
DIFF: https://github.com/llvm/llvm-project/commit/3faec833760fa7ab6e3180378da8c8fb4abbdb11.diff

LOG: [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

Added: 
    

Modified: 
    lldb/source/Expression/REPL.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Expression/REPL.cpp b/lldb/source/Expression/REPL.cpp
index b49b304b3f74..fd7c39686921 100644
--- a/lldb/source/Expression/REPL.cpp
+++ b/lldb/source/Expression/REPL.cpp
@@ -457,6 +457,10 @@ void REPL::IOHandlerComplete(IOHandler &io_handler,
     debugger.GetCommandInterpreter().HandleCompletion(sub_request);
     StringList matches, descriptions;
     sub_result.GetMatches(matches);
+    // Prepend command prefix that was excluded in the completion request.
+    if (request.GetCursorIndex() == 0)
+      for (auto &match : matches)
+        match.insert(0, 1, ':');
     sub_result.GetDescriptions(descriptions);
     request.AddCompletions(matches, descriptions);
     return;


        


More information about the lldb-commits mailing list