Author: Jonas Devlieghere Date: 2024-11-21T08:00:32-08:00 New Revision: 4b5a8d6835897477873242ef1ee529d00dedd9a1
URL: https://github.com/llvm/llvm-project/commit/4b5a8d6835897477873242ef1ee529d00dedd9a1 DIFF: https://github.com/llvm/llvm-project/commit/4b5a8d6835897477873242ef1ee529d00dedd9a1.diff LOG: [lldb] Make sure completions don't end with newlines (#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. Added: Modified: lldb/include/lldb/Utility/CompletionRequest.h Removed: ################################################################################ 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