1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:17:35 +00:00

Kernel+LibVT: Fix selection with scrollback wrap-around

If lines are removed from the tail of the scrollback buffer, the
previous line indices will refer to different lines; therefore we need
to offset them.
This commit is contained in:
Daniel Bertalan 2021-06-05 16:46:33 +02:00 committed by Andreas Kling
parent 13991eade7
commit ce9460de59
7 changed files with 23 additions and 10 deletions

View file

@ -947,13 +947,16 @@ int TerminalWidget::last_selection_column_on_row(int row) const
return row == normalized_selection_end.row() || m_rectangle_selection ? normalized_selection_end.column() : m_terminal.columns() - 1;
}
void TerminalWidget::terminal_history_changed()
void TerminalWidget::terminal_history_changed(int delta)
{
bool was_max = m_scrollbar->value() == m_scrollbar->max();
m_scrollbar->set_max(m_terminal.history_size());
if (was_max)
m_scrollbar->set_value(m_scrollbar->max());
m_scrollbar->update();
// If the history buffer wrapped around, the selection needs to be offset accordingly.
if (m_selection.is_valid() && delta < 0)
m_selection.offset_row(delta);
}
void TerminalWidget::terminal_did_resize(u16 columns, u16 rows)