diff --git a/crates/typst-library/src/layout/flow.rs b/crates/typst-library/src/layout/flow.rs index 802154a02..796b1ac8d 100644 --- a/crates/typst-library/src/layout/flow.rs +++ b/crates/typst-library/src/layout/flow.rs @@ -617,6 +617,7 @@ impl FlowLayouter<'_> { } self.regions.size.y -= self.footnote_config.gap; + let checkpoint = vt.locator.clone(); let frames = FootnoteEntry::new(notes[k].clone()) .pack() .layout(vt, self.styles, self.regions.with_root(false))? @@ -637,6 +638,9 @@ impl FlowLayouter<'_> { self.regions.size.y -= item.height(); } + // Undo Vt modifications. + *vt.locator = checkpoint; + return Ok(false); } diff --git a/crates/typst/src/model/introspect.rs b/crates/typst/src/model/introspect.rs index 90598679b..ebf2ab751 100644 --- a/crates/typst/src/model/introspect.rs +++ b/crates/typst/src/model/introspect.rs @@ -111,7 +111,7 @@ cast! { /// [^1]: Well, we could with [`TrackedMut`](comemo::TrackedMut), but the /// overhead is quite high, especially since we need to save & undo the counting /// when only measuring. -#[derive(Default)] +#[derive(Default, Clone)] pub struct Locator<'a> { /// Maps from a hash to the maximum number we've seen for this hash. This /// number becomes the `disambiguator`.