diff --git a/src/ui/window.c b/src/ui/window.c index 0f6e2780..a9a99f85 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -43,7 +43,7 @@ #include "ai/ai_client.h" static const int PAD_MIN_HEIGHT = 100; -static const int PAD_THRESHOLD = 12000; // above buffer cap (~9000): reclaims dead pad space, never fires while scrolling +static const int PAD_DEAD_SPACE_LIMIT = 2000; // reclaim once the pad holds this much dead space (cursor past live buffer); size-independent, so it never fires while scrolling static gboolean _in_redraw = FALSE; static void @@ -56,9 +56,10 @@ _win_ensure_pad_capacity(ProfWin* window, WINDOW* win, int lines_needed) int cur_height = getmaxy(win); int cur_width = getmaxx(win); if (lines_needed >= cur_height - 1) { - // If we are getting too large, trigger a redraw to clean up old lines - // but only if we are not already in a redraw process. - if (window && cur_height >= PAD_THRESHOLD && !_in_redraw) { + // redraw to reclaim dead pad space (cursor far past live buffer, e.g. a long + // append-only session); dead space never accrues while scrolling, only here + int dead = window ? lines_needed - window->layout->buffer->lines : 0; + if (window && dead > PAD_DEAD_SPACE_LIMIT && !_in_redraw) { win_redraw(window); } else { // resize to required lines + some buffer for next messages