summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/typst-layout/src/flow/compose.rs5
-rw-r--r--tests/ref/issue-5354-footnote-empty-frame-infinite-loop.pngbin0 -> 2342 bytes
-rw-r--r--tests/suite/layout/flow/footnote.typ5
3 files changed, 9 insertions, 1 deletions
diff --git a/crates/typst-layout/src/flow/compose.rs b/crates/typst-layout/src/flow/compose.rs
index 932ccc9a..d49c3fc3 100644
--- a/crates/typst-layout/src/flow/compose.rs
+++ b/crates/typst-layout/src/flow/compose.rs
@@ -431,6 +431,9 @@ impl<'a, 'b> Composer<'a, 'b, '_, '_> {
// Find nested footnotes in the entry.
let nested = find_in_frames::<FootnoteElem>(&frames);
+ // Check if there are any non-empty frames.
+ let exist_non_empty_frame = frames.iter().any(|f| !f.is_empty());
+
// Extract the first frame.
let mut iter = frames.into_iter();
let first = iter.next().unwrap();
@@ -440,7 +443,7 @@ impl<'a, 'b> Composer<'a, 'b, '_, '_> {
// possible, we then migrate the origin frame to the next region to
// uphold the footnote invariant (that marker and entry are on the same
// page). If not, we just queue the footnote for the next page.
- if first.is_empty() {
+ if first.is_empty() && exist_non_empty_frame {
if migratable {
return Err(Stop::Finish(false));
} else {
diff --git a/tests/ref/issue-5354-footnote-empty-frame-infinite-loop.png b/tests/ref/issue-5354-footnote-empty-frame-infinite-loop.png
new file mode 100644
index 00000000..acad56b6
--- /dev/null
+++ b/tests/ref/issue-5354-footnote-empty-frame-infinite-loop.png
Binary files differ
diff --git a/tests/suite/layout/flow/footnote.typ b/tests/suite/layout/flow/footnote.typ
index 3230c3da..63602351 100644
--- a/tests/suite/layout/flow/footnote.typ
+++ b/tests/suite/layout/flow/footnote.typ
@@ -286,3 +286,8 @@ B #footnote[b]
--- issue-4454-footnote-ref-numbering ---
// Test that footnote references are numbered correctly.
A #footnote(numbering: "*")[B]<fn>, C @fn, D @fn, E @fn.
+
+--- issue-5354-footnote-empty-frame-infinite-loop ---
+// Test whether an empty footnote would cause infinite loop
+#show footnote.entry: it => {}
+#lorem(3) #footnote[A footnote]