summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAhmed Hussein <me@ahmedgeek.com>2023-05-12 14:05:22 +0300
committerJelle Raaijmakers <jelle@gmta.nl>2023-06-04 21:28:41 +0200
commitfd9dbf1f201d960deca436f5b8f2fac462358a1c (patch)
tree349f5e69638d1d620cba4fe9b7894c472a85ac1c
parent55e103deb5e3396dc63ee0cf8ad426e248b50f00 (diff)
downloadserenity-fd9dbf1f201d960deca436f5b8f2fac462358a1c.zip
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.
-rw-r--r--Userland/Libraries/LibGUI/TextEditor.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/Userland/Libraries/LibGUI/TextEditor.cpp b/Userland/Libraries/LibGUI/TextEditor.cpp
index 4b875bbd00..8082310433 100644
--- a/Userland/Libraries/LibGUI/TextEditor.cpp
+++ b/Userland/Libraries/LibGUI/TextEditor.cpp
@@ -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;