1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:47:44 +00:00

LibLine: Use the real shown line count around in cleanup()

Previously we would leave artifacts on screen if a change caused the
buffer to span fewer lines than the current buffer.
This commit records the shown line count and uses that instead of trying
to guess the previous line count (and failing most of the time).
This commit is contained in:
Ali Mohammad Pur 2022-06-21 18:40:36 +04:30 committed by Andreas Kling
parent 92a1e9607d
commit 910a44d5f2
2 changed files with 5 additions and 3 deletions

View file

@ -1296,9 +1296,8 @@ void Editor::cleanup()
{
auto current_buffer_metrics = actual_rendered_string_metrics(buffer_view(), m_current_masks);
auto new_lines = current_prompt_metrics().lines_with_addition(current_buffer_metrics, m_num_columns);
auto shown_lines = num_lines();
if (new_lines < shown_lines)
m_extra_forward_lines = max(shown_lines - new_lines, m_extra_forward_lines);
if (new_lines < m_shown_lines)
m_extra_forward_lines = max(m_shown_lines - new_lines, m_extra_forward_lines);
OutputFileStream stderr_stream { stderr };
reposition_cursor(stderr_stream, true);
@ -1313,6 +1312,8 @@ void Editor::refresh_display()
DuplexMemoryStream output_stream;
ScopeGuard flush_stream {
[&] {
m_shown_lines = current_prompt_metrics().lines_with_addition(m_cached_buffer_metrics, m_num_columns);
auto buffer = output_stream.copy_into_contiguous_buffer();
if (buffer.is_empty())
return;