diff --git a/library/src/layout/flow.rs b/library/src/layout/flow.rs index 627ea9886..6940b55ce 100644 --- a/library/src/layout/flow.rs +++ b/library/src/layout/flow.rs @@ -438,6 +438,7 @@ impl FlowLayouter<'_> { find_footnotes(&mut notes, frame); } + let prev_len = self.items.len(); self.items.push(item); // No new footnotes. @@ -473,10 +474,12 @@ impl FlowLayouter<'_> { if !had_footnotes { self.items.pop(); } - let item = self.items.pop(); + let moved: Vec<_> = self.items.drain(prev_len..).collect(); self.finish_region()?; - self.items.extend(item); + self.has_footnotes = + moved.iter().any(|item| matches!(item, FlowItem::Footnote(_))); self.regions.size.y -= height; + self.items.extend(moved); can_skip = false; continue 'outer; } diff --git a/tests/ref/bugs/footnote-keep-multiple.png b/tests/ref/bugs/footnote-keep-multiple.png new file mode 100644 index 000000000..f3b67a745 Binary files /dev/null and b/tests/ref/bugs/footnote-keep-multiple.png differ diff --git a/tests/typ/bugs/footnote-keep-multiple.typ b/tests/typ/bugs/footnote-keep-multiple.typ new file mode 100644 index 000000000..3aa0b9d9e --- /dev/null +++ b/tests/typ/bugs/footnote-keep-multiple.typ @@ -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]