diff --git a/crates/typst/src/layout/flow.rs b/crates/typst/src/layout/flow.rs index 85f67142..8f0def17 100644 --- a/crates/typst/src/layout/flow.rs +++ b/crates/typst/src/layout/flow.rs @@ -257,9 +257,15 @@ impl<'a> FlowLayouter<'a> { let carry: Vec<_> = self.items.drain(sticky..).collect(); self.finish_region(engine, false)?; + let in_last = self.regions.in_last(); + for item in carry { self.layout_item(engine, item)?; } + + if in_last { + break; + } } } diff --git a/tests/ref/bugs/3641-float-loop.png b/tests/ref/bugs/3641-float-loop.png new file mode 100644 index 00000000..092b2ff5 Binary files /dev/null and b/tests/ref/bugs/3641-float-loop.png differ diff --git a/tests/typ/bugs/3641-float-loop.typ b/tests/typ/bugs/3641-float-loop.typ new file mode 100644 index 00000000..4021fb4f --- /dev/null +++ b/tests/typ/bugs/3641-float-loop.typ @@ -0,0 +1,11 @@ +// Flow layout should terminate! +// https://github.com/typst/typst/issues/3641 +// +// This is not yet ideal: The heading should not move to the second page, but +// that's a separate bug and not a regression. + +--- +#set page(height: 40pt) + += Heading +#lorem(6)