1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:08:13 +00:00

TextEditor: Prevent autoscroll looping over

When a text file has only 1 line with long text
autoscroll to the top will no longer loop over
and set the cursor to the end of the line.
This commit is contained in:
Ahmed Hussein 2023-05-12 14:05:22 +03:00 committed by Jelle Raaijmakers
parent 55e103deb5
commit fd9dbf1f20

View file

@ -203,7 +203,7 @@ TextPosition TextEditor::text_position_at_content_position(Gfx::IntPoint content
switch (m_text_alignment) {
case Gfx::TextAlignment::CenterLeft:
for_each_visual_line(line_index, [&](Gfx::IntRect const& rect, auto& view, size_t start_of_line, [[maybe_unused]] bool is_last_visual_line) {
if (is_multi_line() && !rect.contains_vertically(position.y()) && !is_last_visual_line)
if (is_multi_line() && !rect.contains_vertically(position.y()) && !is_last_visual_line && position.y() >= 0)
return IterationDecision::Continue;
column_index = start_of_line;