diff --git a/lldb/include/lldb/Host/File.h b/lldb/include/lldb/Host/File.h --- a/lldb/include/lldb/Host/File.h +++ b/lldb/include/lldb/Host/File.h @@ -327,6 +327,11 @@ /// in lldb_private::File::Permissions. uint32_t GetPermissions(Status &error) const; + /// Ensures that the properties which represent if this file is interactive, + /// a real terminal, and a terminal with colors are calculated eagerly. + void EagerlyCalculateInteractiveAndTerminalProperties(); + + /// Return true if this file is interactive. /// /// \return diff --git a/lldb/source/Core/IOHandler.cpp b/lldb/source/Core/IOHandler.cpp --- a/lldb/source/Core/IOHandler.cpp +++ b/lldb/source/Core/IOHandler.cpp @@ -262,6 +262,18 @@ m_input_sp && m_input_sp->GetIsRealTerminal(); if (use_editline) { +#if defined(__linux__) + // On some Linux distributions, after setting up the EditLine object, + // the eventual call to set_curterm, + // which happens when calculating terminal properties, + // breaks the libedit configuration, causing characters that have + // functions bound to them not to show up. As a workaround, we calculate + // these terminal properties eagerly, before initializing the EditLine + // object. + m_output_sp->GetFile().EagerlyCalculateInteractiveAndTerminalProperties(); + m_error_sp->GetFile().EagerlyCalculateInteractiveAndTerminalProperties(); +#endif + m_editline_up = std::make_unique(editline_name, GetInputFILE(), GetOutputFILE(), GetErrorFILE(), m_color_prompts); diff --git a/lldb/source/Host/common/File.cpp b/lldb/source/Host/common/File.cpp --- a/lldb/source/Host/common/File.cpp +++ b/lldb/source/Host/common/File.cpp @@ -184,6 +184,11 @@ #endif } +void File::EagerlyCalculateInteractiveAndTerminalProperties() { + if (m_supports_colors == eLazyBoolCalculate) + CalculateInteractiveAndTerminal(); +} + bool File::GetIsInteractive() { if (m_is_interactive == eLazyBoolCalculate) CalculateInteractiveAndTerminal();