From 9567694bab7149afbb4e4fcc4c754272a8d25aba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Wed, 1 Jun 2022 19:29:30 +0200 Subject: [PATCH] =?UTF-8?q?grid:=20reflow:=20don=E2=80=99t=20trim=20traili?= =?UTF-8?q?ng=20empty=20cells=20from=20logical=20lines?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a line in the old grid (the one being reflowed) doesn’t have a hard linebreak, don’t trim trailing empty cells. Doing so means we’ll “compress” (remove) empty cells between text if/when we revert to a larger window size. The output from neofetch suffers from this; it prints a logo to the left, and system information to the right. The logo and the system info column is separated by empty cells (i.e. *not* spaces). If the window is reduced in size such that the system info is pushed to a new line, each logo line ends with a number of empty cells. The next time the window is resized, these empty cells were ignored (i.e. removed). That meant that once the window was enlarged again, the system info column was a) no longer aligned, and b) had been pulled closer to the logo. This patch doesn’t special case trailing empty cells when the line being reflowed doesn’t have a hard linebreak. This means e.g. ‘ls’ output is unaffected. Closes #1055 --- CHANGELOG.md | 3 +++ grid.c | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4924572a..44f0ad20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,9 @@ * Graphical corruption when viewport is at the top of the scrollback, and the output is scrolling. +* Improved text reflow of logical lines with trailing empty cells ([#1055][1055]) + +[1055]: https://codeberg.org/dnkl/foot/issues/1055 ### Security diff --git a/grid.c b/grid.c index 736a9f64..bc1018d9 100644 --- a/grid.c +++ b/grid.c @@ -703,6 +703,11 @@ grid_resize_and_reflow( } } + if (!old_row->linebreak /*&& col_count > 0*/) { + /* Don’t truncate logical lines */ + col_count = old_cols; + } + xassert(col_count >= 0 && col_count <= old_cols); /* Do we have a (at least one) tracking point on this row */