From 0c60bb3f295936dff04f56d28ab5dcb4db898a54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Thu, 30 Jun 2022 19:47:18 +0200 Subject: [PATCH] grid: reflow: require col count > 0 when skipping line truncation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When reflowing the grid, we truncate lines with a hard linebreak after the last non-empty cell. This way we don’t reflow trailing empty cells to a new line when resizing the window to a smaller size. However, “logical” lines (i.e. those without a hard linebreak) are *not* truncated. This is to ensure we don’t trim empty cells in the middle of a logical line spanning multiple physical lines. Since newly allocated rows are initialized with linebreak=false, we need to ensure _those_ are still truncated - otherwise all that empty space under the current prompt will be reflowed. Note that this is a temporary workaround. The correct solution, I think, is to track whether a line has been printed to or not, and simply ignore (not reflow) lines that haven’t yet been touched. --- grid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grid.c b/grid.c index 18ca1457..2790d16b 100644 --- a/grid.c +++ b/grid.c @@ -740,7 +740,7 @@ grid_resize_and_reflow( } } - if (!old_row->linebreak /*&& col_count > 0*/) { + if (!old_row->linebreak && col_count > 0) { /* Don’t truncate logical lines */ col_count = old_cols; }