diff options
| author | PgBiel <9021226+PgBiel@users.noreply.github.com> | 2025-06-09 10:46:29 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-09 13:46:29 +0000 |
| commit | 6725061841e327227a49f90134136264a5b8c584 (patch) | |
| tree | 693c2f6a185a03f33d7379f2299b18a2dfdceecd | |
| parent | 494e6a64225261add59c3c9b1cd923bfdfa77961 (diff) | |
Pin colspan and rowspan for blank cells (#6401)
| -rw-r--r-- | crates/typst-library/src/layout/grid/mod.rs | 9 | ||||
| -rw-r--r-- | crates/typst-library/src/model/table.rs | 9 | ||||
| -rw-r--r-- | tests/ref/issue-6399-grid-cell-colspan-set-rule.png | bin | 0 -> 232 bytes | |||
| -rw-r--r-- | tests/ref/issue-6399-grid-cell-rowspan-set-rule.png | bin | 0 -> 232 bytes | |||
| -rw-r--r-- | tests/suite/layout/grid/colspan.typ | 4 | ||||
| -rw-r--r-- | tests/suite/layout/grid/rowspan.typ | 4 |
6 files changed, 24 insertions, 2 deletions
diff --git a/crates/typst-library/src/layout/grid/mod.rs b/crates/typst-library/src/layout/grid/mod.rs index 6616c331..369df11e 100644 --- a/crates/typst-library/src/layout/grid/mod.rs +++ b/crates/typst-library/src/layout/grid/mod.rs @@ -755,7 +755,14 @@ impl Show for Packed<GridCell> { impl Default for Packed<GridCell> { fn default() -> Self { - Packed::new(GridCell::new(Content::default())) + Packed::new( + // Explicitly set colspan and rowspan to ensure they won't be + // overridden by set rules (default cells are created after + // colspans and rowspans are processed in the resolver) + GridCell::new(Content::default()) + .with_colspan(NonZeroUsize::ONE) + .with_rowspan(NonZeroUsize::ONE), + ) } } diff --git a/crates/typst-library/src/model/table.rs b/crates/typst-library/src/model/table.rs index 6f4461bd..37323089 100644 --- a/crates/typst-library/src/model/table.rs +++ b/crates/typst-library/src/model/table.rs @@ -770,7 +770,14 @@ impl Show for Packed<TableCell> { impl Default for Packed<TableCell> { fn default() -> Self { - Packed::new(TableCell::new(Content::default())) + Packed::new( + // Explicitly set colspan and rowspan to ensure they won't be + // overridden by set rules (default cells are created after + // colspans and rowspans are processed in the resolver) + TableCell::new(Content::default()) + .with_colspan(NonZeroUsize::ONE) + .with_rowspan(NonZeroUsize::ONE), + ) } } diff --git a/tests/ref/issue-6399-grid-cell-colspan-set-rule.png b/tests/ref/issue-6399-grid-cell-colspan-set-rule.png Binary files differnew file mode 100644 index 00000000..a40eda78 --- /dev/null +++ b/tests/ref/issue-6399-grid-cell-colspan-set-rule.png diff --git a/tests/ref/issue-6399-grid-cell-rowspan-set-rule.png b/tests/ref/issue-6399-grid-cell-rowspan-set-rule.png Binary files differnew file mode 100644 index 00000000..a40eda78 --- /dev/null +++ b/tests/ref/issue-6399-grid-cell-rowspan-set-rule.png diff --git a/tests/suite/layout/grid/colspan.typ b/tests/suite/layout/grid/colspan.typ index 707a9456..6e43270c 100644 --- a/tests/suite/layout/grid/colspan.typ +++ b/tests/suite/layout/grid/colspan.typ @@ -140,3 +140,7 @@ [e], [g], grid.cell(colspan: 2)[eee\ e\ e\ e], grid.cell(colspan: 4)[eeee e e e] ) + +--- issue-6399-grid-cell-colspan-set-rule --- +#set grid.cell(colspan: 2) +#grid(columns: 3, [hehe]) diff --git a/tests/suite/layout/grid/rowspan.typ b/tests/suite/layout/grid/rowspan.typ index 88aa34c6..5fc28b9b 100644 --- a/tests/suite/layout/grid/rowspan.typ +++ b/tests/suite/layout/grid/rowspan.typ @@ -488,3 +488,7 @@ table.cell(rowspan: 15, align: horizon, lets-repeat((rotate(-90deg, reflow: true)[*All Tests*]), 3)), ..([123], [456], [789]) * 15 ) + +--- issue-6399-grid-cell-rowspan-set-rule --- +#set grid.cell(rowspan: 2) +#grid(columns: 2, [hehe]) |
