Fix a bug in footnote together-keeping logic

This commit is contained in:
Laurenz 2023-06-08 11:21:35 +02:00
parent 10ae0a2c2b
commit f3e3061a7f
3 changed files with 15 additions and 2 deletions

View File

@ -438,6 +438,7 @@ impl FlowLayouter<'_> {
find_footnotes(&mut notes, frame); find_footnotes(&mut notes, frame);
} }
let prev_len = self.items.len();
self.items.push(item); self.items.push(item);
// No new footnotes. // No new footnotes.
@ -473,10 +474,12 @@ impl FlowLayouter<'_> {
if !had_footnotes { if !had_footnotes {
self.items.pop(); self.items.pop();
} }
let item = self.items.pop(); let moved: Vec<_> = self.items.drain(prev_len..).collect();
self.finish_region()?; self.finish_region()?;
self.items.extend(item); self.has_footnotes =
moved.iter().any(|item| matches!(item, FlowItem::Footnote(_)));
self.regions.size.y -= height; self.regions.size.y -= height;
self.items.extend(moved);
can_skip = false; can_skip = false;
continue 'outer; continue 'outer;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -0,0 +1,10 @@
// Test that the logic that keeps footnote entry together with
// their markers also works for multiple footnotes in a single
// line or frame (here, there are two lines, but they are one
// unit due to orphan prevention).
---
#set page(height: 100pt)
#v(30pt)
A #footnote[a] \
B #footnote[b]