From 979f300337c6411d037511600146303d6eca3ffd Mon Sep 17 00:00:00 2001 From: ryanb-dev Date: Tue, 28 Dec 2021 09:44:30 -0600 Subject: [PATCH] LibVT: Handle window resize after history overflow Addresses an issue in which a window resize event after history overflow would cause the Terminal to crash due to a failed assertion. The problematic assertion was removed and the logic updated to support inserting lines even when the start of the history is at an offset (due to an overflow). Resolves #10987 --- Userland/Libraries/LibVT/Terminal.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibVT/Terminal.h b/Userland/Libraries/LibVT/Terminal.h index 5313d20715..7146317bc8 100644 --- a/Userland/Libraries/LibVT/Terminal.h +++ b/Userland/Libraries/LibVT/Terminal.h @@ -388,9 +388,14 @@ protected: if (max_history_size() == 0) return; + // If m_history can expand, add the new line to the end of the list. + // If there is an overflow wrap, the end is at the index before the start. if (m_history.size() < max_history_size()) { - VERIFY(m_history_start == 0); - m_history.append(move(line)); + if (m_history_start == 0) + m_history.append(move(line)); + else + m_history.insert(m_history_start - 1, move(line)); + return; } m_history.ptr_at(m_history_start) = move(line);