diff --git a/src/ui/window.c b/src/ui/window.c index f0ec5bbb..2bf576fd 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -2001,7 +2001,19 @@ _win_print_internal(ProfWin* window, const char* show_char, int pad_indent, GDat } } - _win_ensure_pad_capacity(window, window->layout->win, getcury(window->layout->win)); + // reserve pad rows for this message's full height so a tall message isn't clipped at the pad bottom (a clipped height desyncs the scroll offset) + int usable = getmaxx(window->layout->win) - (indent + pad_indent); + if (usable < 1) { + usable = 1; + } + int msg_nl = 0; + for (const char* mp = message + offset; *mp; mp++) { + if (*mp == '\n') { + msg_nl++; + } + } + int est_lines = msg_nl + (int)(utf8_display_len(message + offset) / usable) + 2; + _win_ensure_pad_capacity(window, window->layout->win, getcury(window->layout->win) + est_lines); if (prefs_get_boolean(PREF_WRAP)) { _win_print_wrapped(window->layout->win, message + offset, indent, pad_indent);