From 3e6a0a05338f1bd05276140528a3e15349cbbc2e Mon Sep 17 00:00:00 2001 From: Rhin Date: Sun, 1 Sep 2019 05:34:14 -0500 Subject: [PATCH] TextEditor: Stopped disappearing text at end of document (#505) text_position_at() was returning -1 if the position wasn't in the bounds of a visual line. Now if the position is past the last line, we simply return the last line index instead of -1. Fixes #502. --- Libraries/LibGUI/GTextEditor.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Libraries/LibGUI/GTextEditor.cpp b/Libraries/LibGUI/GTextEditor.cpp index 6fb7aa7219..53d3477290 100644 --- a/Libraries/LibGUI/GTextEditor.cpp +++ b/Libraries/LibGUI/GTextEditor.cpp @@ -139,7 +139,8 @@ GTextPosition GTextEditor::text_position_at(const Point& a_position) const if (position.y() >= rect.top() && position.y() <= rect.bottom()) { line_index = i; break; - } + } else if (position.y() > rect.bottom()) + line_index = m_lines.size() - 1; } } else { line_index = position.y() / line_height();