mirror of
https://github.com/RGBCube/serenity
synced 2025-05-19 17:25:07 +00:00
GTextEditor: Go a little past the cursor for Home/End scroll-into-view.
When jumping to the start of a line, or to the end of a line, scrolling two pixels past the end yields a pleasant effect.
This commit is contained in:
parent
2c51bc92af
commit
7a5525edf4
1 changed files with 6 additions and 1 deletions
|
@ -605,7 +605,12 @@ Rect GTextEditor::line_widget_rect(int line_index) const
|
|||
|
||||
void GTextEditor::scroll_cursor_into_view()
|
||||
{
|
||||
scroll_into_view(cursor_content_rect(), true, true);
|
||||
auto rect = cursor_content_rect();
|
||||
if (m_cursor.column() == 0)
|
||||
rect.set_x(content_x_for_position({ m_cursor.line(), 0 }) - 2);
|
||||
else if (m_cursor.column() == m_lines[m_cursor.line()]->length())
|
||||
rect.set_x(content_x_for_position({ m_cursor.line(), m_lines[m_cursor.line()]->length() }) + 2);
|
||||
scroll_into_view(rect, true, true);
|
||||
}
|
||||
|
||||
Rect GTextEditor::line_content_rect(int line_index) const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue