mirror of
https://github.com/typst/typst
synced 2025-05-14 17:15:28 +08:00
Fix duplicate state manipulation
The flow layouts footnotes twice in some cases, which messed up the Vt's locator state. Typically, we use `thing.measure` instead of `thing.layout` to prevent side effects, but in this case it was simpler to just undo the modification. A future layout engine rewrite should try to make this kind of error harder to make. Fixes #1597
This commit is contained in:
parent
25613cfaf3
commit
72d8a9c89a
@ -617,6 +617,7 @@ impl FlowLayouter<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.regions.size.y -= self.footnote_config.gap;
|
self.regions.size.y -= self.footnote_config.gap;
|
||||||
|
let checkpoint = vt.locator.clone();
|
||||||
let frames = FootnoteEntry::new(notes[k].clone())
|
let frames = FootnoteEntry::new(notes[k].clone())
|
||||||
.pack()
|
.pack()
|
||||||
.layout(vt, self.styles, self.regions.with_root(false))?
|
.layout(vt, self.styles, self.regions.with_root(false))?
|
||||||
@ -637,6 +638,9 @@ impl FlowLayouter<'_> {
|
|||||||
self.regions.size.y -= item.height();
|
self.regions.size.y -= item.height();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Undo Vt modifications.
|
||||||
|
*vt.locator = checkpoint;
|
||||||
|
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ cast! {
|
|||||||
/// [^1]: Well, we could with [`TrackedMut`](comemo::TrackedMut), but the
|
/// [^1]: Well, we could with [`TrackedMut`](comemo::TrackedMut), but the
|
||||||
/// overhead is quite high, especially since we need to save & undo the counting
|
/// overhead is quite high, especially since we need to save & undo the counting
|
||||||
/// when only measuring.
|
/// when only measuring.
|
||||||
#[derive(Default)]
|
#[derive(Default, Clone)]
|
||||||
pub struct Locator<'a> {
|
pub struct Locator<'a> {
|
||||||
/// Maps from a hash to the maximum number we've seen for this hash. This
|
/// Maps from a hash to the maximum number we've seen for this hash. This
|
||||||
/// number becomes the `disambiguator`.
|
/// number becomes the `disambiguator`.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user