--- rxvt-unicode/src/screen.C 2022/08/04 18:28:44 1.465 +++ rxvt-unicode/src/screen.C 2022/08/08 10:31:51 1.471 @@ -334,12 +334,12 @@ int qlines = max (0, (llen - 1) / ncol) + 1; - q -= qlines; - // drop partial lines completely - if (q < 0) + if (q < qlines) break; + q -= qlines; + int lofs = 0; line_t *qline; @@ -389,15 +389,13 @@ scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE); } while (p != pend && q > 0); - - // make sure all terminal lines exist - while (top_row > 0) - scr_blank_screen_mem (ROW (--top_row), DEFAULT_RSTYLE); } else #endif { // wing, instead of wrap + screen.cur.row += nrow - prev_nrow; + do { p = MOD (p - 1, prev_total_rows); @@ -405,14 +403,17 @@ copy_line (row_buf [q], prev_row_buf [p]); } - while (p != pend); + while (p != pend && q > 0); - screen.cur.row += nrow - prev_nrow; } term_start = total_rows - nrow; top_row = q - term_start; + // make sure all terminal lines exist + while (top_row > 0) + scr_blank_screen_mem (ROW (--top_row), DEFAULT_RSTYLE); + clamp_it (screen.cur.row, 0, nrow - 1); clamp_it (screen.cur.col, 0, ncol - 1); }