diff options
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/typst/src/layout/grid/layout.rs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/crates/typst/src/layout/grid/layout.rs b/crates/typst/src/layout/grid/layout.rs index 6d89b73c..645b68b6 100644 --- a/crates/typst/src/layout/grid/layout.rs +++ b/crates/typst/src/layout/grid/layout.rs @@ -847,15 +847,26 @@ impl CellGrid { } } + // If the user specified cells occupying less rows than the given rows, + // we shall expand the grid so that it has at least the given amount of + // rows. + let Some(expected_total_cells) = c.checked_mul(tracks.y.len()) else { + bail!(span, "too many rows were specified"); + }; + let missing_cells = expected_total_cells.saturating_sub(resolved_cells.len()); + // Fixup phase (final step in cell grid generation): // 1. Replace absent entries by resolved empty cells, and produce a // vector of 'Entry' from 'Option<Entry>'. - // 2. If any cells were added to the header's rows after the header's + // 2. Add enough empty cells to the end of the grid such that it has at + // least the given amount of rows. + // 3. If any cells were added to the header's rows after the header's // creation, ensure the header expands enough to accommodate them // across all of their spanned rows. Same for the footer. - // 3. If any cells before the footer try to span it, error. + // 4. If any cells before the footer try to span it, error. let resolved_cells = resolved_cells .into_iter() + .chain(std::iter::repeat_with(|| None).take(missing_cells)) .enumerate() .map(|(i, cell)| { if let Some(cell) = cell { |
