Fix non-terminating loop in flow layout (#3652)

This commit is contained in:
Laurenz 2024-03-13 14:46:00 +01:00 committed by GitHub
parent 28012b2f8d
commit 7c61ccac71
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 0 deletions

View File

@ -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;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -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)