mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-05 16:14:38 +00:00
GTextEditor: Fix text_position_at() behavior when passed negative values.
This commit is contained in:
@@ -100,8 +100,8 @@ GTextPosition GTextEditor::text_position_at(const Point& a_position) const
|
||||
position.move_by(-(padding() + ruler_width()), -padding());
|
||||
int line_index = position.y() / line_height();
|
||||
int column_index = position.x() / glyph_width();
|
||||
line_index = min(line_index, line_count() - 1);
|
||||
column_index = min(column_index, m_lines[line_index]->length());
|
||||
line_index = max(0, min(line_index, line_count() - 1));
|
||||
column_index = max(0, min(column_index, m_lines[line_index]->length()));
|
||||
return { line_index, column_index };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user