https://github.com/JDevlieghere created 
https://github.com/llvm/llvm-project/pull/117054

The logic that prints completions and their descriptions assumes neither the 
completion itself nor the description ends with a newline. I considered making 
this an assert, but decided against it as completions can indirectly come from 
user input (e.g. oddly crafted names). Instead, avoid the potential for 
mistakes by defensively stripping them.

>From e5dfed25b6dd1523a1818fe82a921537956d0693 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jo...@devlieghere.com>
Date: Wed, 20 Nov 2024 13:22:09 -0800
Subject: [PATCH] [lldb] Make sure completions don't end with newlines

The logic that prints completions and their descriptions assumes neither
the completion itself nor the description ends with a newline. I
considered making this an assert, but decided against it as completions
can indirectly come from user input (e.g. oddly crafted names). Instead,
avoid the potential for mistakes by defensively stripping them.
---
 lldb/include/lldb/Utility/CompletionRequest.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/include/lldb/Utility/CompletionRequest.h 
b/lldb/include/lldb/Utility/CompletionRequest.h
index 650158a197dbd9..865d6db5762984 100644
--- a/lldb/include/lldb/Utility/CompletionRequest.h
+++ b/lldb/include/lldb/Utility/CompletionRequest.h
@@ -52,8 +52,8 @@ class CompletionResult {
   public:
     Completion(llvm::StringRef completion, llvm::StringRef description,
                CompletionMode mode)
-        : m_completion(completion.str()), m_descripton(description.str()),
-          m_mode(mode) {}
+        : m_completion(completion.rtrim().str()),
+          m_descripton(description.rtrim().str()), m_mode(mode) {}
     const std::string &GetCompletion() const { return m_completion; }
     const std::string &GetDescription() const { return m_descripton; }
     CompletionMode GetMode() const { return m_mode; }

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to