Always ensure we do not scroll past the last line

An assert fails from time to time after reloading fifo buffers due
to being scrolled past the last line of the buffer. A repro case was
not found but this should fix the underlying issue.
This commit is contained in:
Maxime Coste 2023-11-01 17:23:53 +11:00
parent 2fa55be40a
commit 8cc4de5bb3

View File

@ -209,8 +209,9 @@ DisplaySetup Window::compute_display_setup(const Context& context) const
if (cursor.line - offset.line < win_pos.line)
win_pos.line = std::max(0_line, cursor.line - offset.line);
if (cursor.line + offset.line >= win_pos.line + m_dimensions.line)
win_pos.line = std::min(buffer().line_count()-1, cursor.line + offset.line - m_dimensions.line + 1);
win_pos.line = cursor.line + offset.line - m_dimensions.line + 1;
}
win_pos.line = std::min(win_pos.line, buffer().line_count()-1);
DisplaySetup setup{
win_pos.line,