diff --git a/Libraries/LibLine/Editor.cpp b/Libraries/LibLine/Editor.cpp index 2f7115da94..438bca11a7 100644 --- a/Libraries/LibLine/Editor.cpp +++ b/Libraries/LibLine/Editor.cpp @@ -1031,6 +1031,11 @@ size_t Editor::actual_rendered_string_length(const StringView& string) const state = Escape; continue; } + if (c == '\r' || c == '\n') { + // reset length to 0, since we either overwrite, or are on a newline + length = 0; + continue; + } // FIXME: This will not support anything sophisticated ++length; break; diff --git a/Libraries/LibLine/Editor.h b/Libraries/LibLine/Editor.h index 90dc5aef79..d911deb5dc 100644 --- a/Libraries/LibLine/Editor.h +++ b/Libraries/LibLine/Editor.h @@ -130,6 +130,7 @@ public: const Vector& history() const { return m_history; } void register_character_input_callback(char ch, Function callback); + size_t actual_rendered_string_length(const StringView& string) const; Function(const String&)> on_tab_complete_first_token; Function(const String&)> on_tab_complete_other_token; @@ -252,8 +253,6 @@ private: return (m_drawn_cursor + current_prompt_length()) % m_num_columns; } - size_t actual_rendered_string_length(const StringView& string) const; - void set_origin() { auto position = vt_dsr();