From 9b09146a6b5e936966ed7ee73bce9dd2df3810ae Mon Sep 17 00:00:00 2001 From: Tobias Schmitz Date: Tue, 6 May 2025 16:03:48 +0200 Subject: [PATCH] Use list spacing for attach spacing in tight lists (#6242) --- crates/typst-library/src/model/enum.rs | 9 +++++---- crates/typst-library/src/model/list.rs | 9 +++++---- crates/typst-library/src/model/terms.rs | 8 +++++--- .../ref/issue-6242-tight-list-attach-spacing.png | Bin 0 -> 410 bytes tests/suite/model/list.typ | 8 ++++++++ 5 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 tests/ref/issue-6242-tight-list-attach-spacing.png diff --git a/crates/typst-library/src/model/enum.rs b/crates/typst-library/src/model/enum.rs index 2d95996ab..f1f93702b 100644 --- a/crates/typst-library/src/model/enum.rs +++ b/crates/typst-library/src/model/enum.rs @@ -259,10 +259,11 @@ impl Show for Packed { .spanned(self.span()); if tight { - let leading = ParElem::leading_in(styles); - let spacing = - VElem::new(leading.into()).with_weak(true).with_attach(true).pack(); - realized = spacing + realized; + let spacing = self + .spacing(styles) + .unwrap_or_else(|| ParElem::leading_in(styles).into()); + let v = VElem::new(spacing.into()).with_weak(true).with_attach(true).pack(); + realized = v + realized; } Ok(realized) diff --git a/crates/typst-library/src/model/list.rs b/crates/typst-library/src/model/list.rs index d93ec9172..3c3afd338 100644 --- a/crates/typst-library/src/model/list.rs +++ b/crates/typst-library/src/model/list.rs @@ -166,10 +166,11 @@ impl Show for Packed { .spanned(self.span()); if tight { - let leading = ParElem::leading_in(styles); - let spacing = - VElem::new(leading.into()).with_weak(true).with_attach(true).pack(); - realized = spacing + realized; + let spacing = self + .spacing(styles) + .unwrap_or_else(|| ParElem::leading_in(styles).into()); + let v = VElem::new(spacing.into()).with_weak(true).with_attach(true).pack(); + realized = v + realized; } Ok(realized) diff --git a/crates/typst-library/src/model/terms.rs b/crates/typst-library/src/model/terms.rs index e197ff318..3df74cd9e 100644 --- a/crates/typst-library/src/model/terms.rs +++ b/crates/typst-library/src/model/terms.rs @@ -189,13 +189,15 @@ impl Show for Packed { .styled(TermsElem::set_within(true)); if tight { - let leading = ParElem::leading_in(styles); - let spacing = VElem::new(leading.into()) + let spacing = self + .spacing(styles) + .unwrap_or_else(|| ParElem::leading_in(styles).into()); + let v = VElem::new(spacing.into()) .with_weak(true) .with_attach(true) .pack() .spanned(span); - realized = spacing + realized; + realized = v + realized; } Ok(realized) diff --git a/tests/ref/issue-6242-tight-list-attach-spacing.png b/tests/ref/issue-6242-tight-list-attach-spacing.png new file mode 100644 index 0000000000000000000000000000000000000000..48920008b1350f8b604d4e06842d25b282ae1afd GIT binary patch literal 410 zcmV;L0cHM)P)0004DNkl_mzthIoO<(BZ&hpc2JIEVmAj-D~C-E!p%iy#TpKiDY3^`zc26O_^cr~*i$nC=fnOZLAW@u z4gf5kZj1@SXHC5TQ1Mz;cS#N=Rseud8kRTZGrsj6P+jrmwLlbBSYd_#0i2By8sZG5zg4v90VZUCk*?O0PyXO zLgqz2W6G<6ohvO6g%ws<;l_k>sj><9b^1Iucx(V3zlXQ5Ap8jc^$y{Tv#pZ=l-h;i zo0bs(aAtuYIhc~YlkUsne#XQ*RpXI&Z7zisR=8o|U!MOHPD9hDwg3PC07*qoM6N<$ Eg2vyu4*&oF literal 0 HcmV?d00001 diff --git a/tests/suite/model/list.typ b/tests/suite/model/list.typ index 9bed930bb..796a7b069 100644 --- a/tests/suite/model/list.typ +++ b/tests/suite/model/list.typ @@ -304,3 +304,11 @@ World - C - = D E + +--- issue-6242-tight-list-attach-spacing --- +// Nested tight lists should be uniformly spaced when list spacing is set. +#set list(spacing: 1.2em) +- A + - B + - C +- C