summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--library/src/layout/flow.rs7
-rw-r--r--tests/ref/bugs/footnote-keep-multiple.pngbin0 -> 1914 bytes
-rw-r--r--tests/typ/bugs/footnote-keep-multiple.typ10
3 files changed, 15 insertions, 2 deletions
diff --git a/library/src/layout/flow.rs b/library/src/layout/flow.rs
index 627ea988..6940b55c 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 00000000..f3b67a74
--- /dev/null
+++ b/tests/ref/bugs/footnote-keep-multiple.png
Binary files differ
diff --git a/tests/typ/bugs/footnote-keep-multiple.typ b/tests/typ/bugs/footnote-keep-multiple.typ
new file mode 100644
index 00000000..3aa0b9d9
--- /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]