mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
selection: foreach_selection_*: must wrap row number
Fixes occasional crashes when we're at the end of the grid and selection wraps around.
This commit is contained in:
parent
7e178d6337
commit
6833abf33c
1 changed files with 6 additions and 2 deletions
|
|
@ -74,7 +74,9 @@ foreach_selected_normal(
|
|||
}
|
||||
|
||||
for (int r = start_row; r <= end_row; r++) {
|
||||
struct row *row = term->grid->rows[r];
|
||||
size_t real_r = r & (term->grid->num_rows - 1);
|
||||
struct row *row = term->grid->rows[real_r];
|
||||
assert(row != NULL);
|
||||
|
||||
for (int c = start_col;
|
||||
c <= (r == end_row ? end_col : term->cols - 1);
|
||||
|
|
@ -107,7 +109,9 @@ foreach_selected_block(
|
|||
};
|
||||
|
||||
for (int r = top_left.row; r <= bottom_right.row; r++) {
|
||||
struct row *row = term->grid->rows[r];
|
||||
size_t real_r = r & (term->grid->num_rows - 1);
|
||||
struct row *row = term->grid->rows[real_r];
|
||||
assert(row != NULL);
|
||||
|
||||
for (int c = top_left.col; c <= bottom_right.col; c++)
|
||||
cb(term, row, &row->cells[c], data);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue