1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 22:48:11 +00:00

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.
This commit is contained in:
Rhin 2019-09-01 05:34:14 -05:00 committed by Andreas Kling
parent 3e2e086011
commit 3e6a0a0533

View file

@ -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();