grid: reflow: don’t trim trailing empty cells from logical lines

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
This commit is contained in:
Daniel Eklöf 2022-06-01 19:29:30 +02:00
parent cdd46cdf85
commit 9567694bab
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 8 additions and 0 deletions

5
grid.c
View file

@ -703,6 +703,11 @@ grid_resize_and_reflow(
}
}
if (!old_row->linebreak /*&& col_count > 0*/) {
/* Dont 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 */