From abcc5342eee8e7e2fc22b3b35bc0afeaf9e8192c Mon Sep 17 00:00:00 2001 From: "neovim-backports[bot]" <175700243+neovim-backports[bot]@users.noreply.github.com> Date: Mon, 13 Apr 2026 18:31:24 -0400 Subject: [PATCH] fix(terminal): do not reflow altscreen on resize #39024 Problem: reflow can break tui display Solution: disable reflow on altscreen (cherry picked from commit 7bb8231577d11b31cbc85b563c6bc299b64957d4) Co-authored-by: phanium <91544758+phanen@users.noreply.github.com> --- src/nvim/vterm/screen.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/nvim/vterm/screen.c b/src/nvim/vterm/screen.c index 1206373241..99c8e61748 100644 --- a/src/nvim/vterm/screen.c +++ b/src/nvim/vterm/screen.c @@ -498,17 +498,19 @@ static void resize_buffer(VTermScreen *screen, int bufidx, int new_rows, int new // scrolling into int final_blank_row = new_rows; + bool do_reflow = screen->reflow && (bufidx == BUFIDX_PRIMARY); + while (old_row >= 0) { int old_row_end = old_row; // TODO(vterm): Stop if dwl or dhl - while (screen->reflow && old_lineinfo && old_row > 0 && old_lineinfo[old_row].continuation) { + while (do_reflow && old_lineinfo && old_row > 0 && old_lineinfo[old_row].continuation) { old_row--; } int old_row_start = old_row; int width = 0; for (int row = old_row_start; row <= old_row_end; row++) { - if (screen->reflow && row < (old_rows - 1) && old_lineinfo[row + 1].continuation) { + if (do_reflow && row < (old_rows - 1) && old_lineinfo[row + 1].continuation) { width += old_cols; } else { width += line_popcount(old_buffer, row, old_rows, old_cols); @@ -519,7 +521,7 @@ static void resize_buffer(VTermScreen *screen, int bufidx, int new_rows, int new final_blank_row = new_row; } - int new_height = screen->reflow + int new_height = do_reflow ? width ? (width + new_cols - 1) / new_cols : 1 : 1; @@ -595,7 +597,7 @@ static void resize_buffer(VTermScreen *screen, int bufidx, int new_rows, int new if (old_col == old_cols) { old_row++; - if (!screen->reflow) { + if (!do_reflow) { new_col++; break; }