diff options
| author | Laurenz <laurmaedje@gmail.com> | 2024-03-13 14:46:00 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-13 13:46:00 +0000 |
| commit | 7c61ccac71fbdc4fd6fe905f86703b48a53c8d06 (patch) | |
| tree | 3b9930681c7ce129297eed969ed4c95f2b817749 | |
| parent | 28012b2f8dbbaf8ae168c7afd33f2f9e00a7d840 (diff) | |
Fix non-terminating loop in flow layout (#3652)
| -rw-r--r-- | crates/typst/src/layout/flow.rs | 6 | ||||
| -rw-r--r-- | tests/ref/bugs/3641-float-loop.png | bin | 0 -> 3904 bytes | |||
| -rw-r--r-- | tests/typ/bugs/3641-float-loop.typ | 11 |
3 files changed, 17 insertions, 0 deletions
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 Binary files differnew file mode 100644 index 00000000..092b2ff5 --- /dev/null +++ b/tests/ref/bugs/3641-float-loop.png 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) |
