From 6720d8c3017af787b8dce42e9fa15468f281629d Mon Sep 17 00:00:00 2001 From: Laurenz Date: Mon, 12 Jun 2023 17:20:49 +0200 Subject: Fix bug with missing table row Fixes #1388 --- library/src/layout/grid.rs | 4 ++-- library/src/layout/table.rs | 4 ++-- tests/ref/bugs/table-row-missing.png | Bin 0 -> 1029 bytes tests/typ/bugs/table-row-missing.typ | 8 ++++++++ 4 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 tests/ref/bugs/table-row-missing.png create mode 100644 tests/typ/bugs/table-row-missing.typ diff --git a/library/src/layout/grid.rs b/library/src/layout/grid.rs index ea155acd..acf13d64 100644 --- a/library/src/layout/grid.rs +++ b/library/src/layout/grid.rs @@ -293,7 +293,7 @@ impl<'a, 'v> GridLayouter<'a, 'v> { for y in 0..self.rows.len() { // Skip to next region if current one is full, but only for content // rows, not for gutter rows. - if y % 2 == 0 && self.regions.is_full() { + if self.regions.is_full() && (!self.has_gutter || y % 2 == 0) { self.finish_region()?; } @@ -547,7 +547,7 @@ impl<'a, 'v> GridLayouter<'a, 'v> { self.finish_region()?; // Don't skip multiple regions for gutter and don't push a row. - if y % 2 == 1 { + if self.has_gutter && y % 2 == 1 { return Ok(()); } } diff --git a/library/src/layout/table.rs b/library/src/layout/table.rs index 44f18586..3235c790 100644 --- a/library/src/layout/table.rs +++ b/library/src/layout/table.rs @@ -222,8 +222,8 @@ impl Layout for TableElem { } } -/// Turn an iterator extents into an iterator of offsets before, in between, and -/// after the extents, e.g. [10mm, 5mm] -> [0mm, 10mm, 15mm]. +/// Turn an iterator of extents into an iterator of offsets before, in between, +/// and after the extents, e.g. [10mm, 5mm] -> [0mm, 10mm, 15mm]. fn points(extents: impl IntoIterator) -> impl Iterator { let mut offset = Abs::zero(); std::iter::once(Abs::zero()) diff --git a/tests/ref/bugs/table-row-missing.png b/tests/ref/bugs/table-row-missing.png new file mode 100644 index 00000000..90c46d32 Binary files /dev/null and b/tests/ref/bugs/table-row-missing.png differ diff --git a/tests/typ/bugs/table-row-missing.typ b/tests/typ/bugs/table-row-missing.typ new file mode 100644 index 00000000..d72305ba --- /dev/null +++ b/tests/typ/bugs/table-row-missing.typ @@ -0,0 +1,8 @@ +// Test that a table row isn't wrongly treated like a gutter row. + +--- +#set page(height: 70pt) +#table( + rows: 16pt, + ..range(6).map(str).flatten(), +) -- cgit v1.2.3