aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-07-14 10:15:25 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-07-14 10:15:25 +0000
commit3fd61fa1203c9061394952a5efdc864b37d64cff (patch)
tree69b380494fd137916b7a2f92cdd1a054ccc29de0
parentterm: remove assert, as we're already checking for this in the loop condition (diff)
grid: reflow: always emit *all* cells of a multi-column character
-rw-r--r--grid.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/grid.c b/grid.c
index 3a170c1c..d2905a93 100644
--- a/grid.c
+++ b/grid.c
@@ -217,7 +217,12 @@ grid_reflow(struct grid *grid, int new_rows, int new_cols,
if (new_cols_left < cols_needed && new_cols_left >= old_cols_left)
empty_count = max(0, empty_count - (cols_needed - new_cols_left));
- for (int i = 0; i < empty_count + 1; i++) {
+ int width = max(1, wcwidth(old_row->cells[c].wc));
+
+ /* Multi-column characters are never cut in half */
+ assert(c + width <= old_cols);
+
+ for (int i = 0; i < empty_count + width; i++) {
const struct cell *old_cell = &old_row->cells[c - empty_count + i];
/* Out of columns on current row in new grid? */
@@ -244,6 +249,7 @@ grid_reflow(struct grid *grid, int new_rows, int new_cols,
new_col_idx++;
}
+ c += width - 1;
empty_count = 0;
}