From 96f9187841eacf4191e183403e550fe258d0d559 Mon Sep 17 00:00:00 2001 From: Efe Akinci Date: Thu, 6 Mar 2025 23:19:08 -0500 Subject: [PATCH] Add back removed comment --- crates/typst-layout/src/flow/distribute.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/crates/typst-layout/src/flow/distribute.rs b/crates/typst-layout/src/flow/distribute.rs index 6efb6da58..169e71f99 100644 --- a/crates/typst-layout/src/flow/distribute.rs +++ b/crates/typst-layout/src/flow/distribute.rs @@ -347,6 +347,23 @@ impl<'a, 'b> Distributor<'a, 'b, '_, '_, '_> { .unwrap_or(false); let mut stick_to_successor = || { + // If the frame is sticky and we haven't remembered a preceding + // sticky element, make a checkpoint which we can restore should we + // end on this sticky element. + // + // The first sticky block within consecutive sticky blocks + // determines whether this group of sticky blocks has stickiness + // disabled or not. + // + // The criteria used here is: if migrating this group of sticky + // blocks together with the "attached" block can't improve the lack + // of space, since we're at the start of the region, then we don't + // do so, and stickiness is disabled (at least, for this region). + // Otherwise, migration is allowed. + // + // Note that, since the whole region is checked, this ensures sticky + // blocks at the top of a block - but not necessarily of the page - + // can still be migrated. if self.sticky.is_none() && *self.stickable.get_or_insert_with(|| self.regions.may_progress()) {