mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Fix paragraph layouting index out of bounds bug (#3607)
This commit is contained in:
parent
443cf60ae2
commit
6e0b3484dd
@ -244,6 +244,8 @@ impl<'a> FlowLayouter<'a> {
|
|||||||
)?
|
)?
|
||||||
.into_frames();
|
.into_frames();
|
||||||
|
|
||||||
|
if let Some(first) = lines.first() {
|
||||||
|
while !self.regions.size.y.fits(first.height()) && !self.regions.in_last() {
|
||||||
let mut sticky = self.items.len();
|
let mut sticky = self.items.len();
|
||||||
for (i, item) in self.items.iter().enumerate().rev() {
|
for (i, item) in self.items.iter().enumerate().rev() {
|
||||||
match *item {
|
match *item {
|
||||||
@ -253,8 +255,6 @@ impl<'a> FlowLayouter<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(first) = lines.first() {
|
|
||||||
while !self.regions.size.y.fits(first.height()) && !self.regions.in_last() {
|
|
||||||
let carry: Vec<_> = self.items.drain(sticky..).collect();
|
let carry: Vec<_> = self.items.drain(sticky..).collect();
|
||||||
self.finish_region(engine, false)?;
|
self.finish_region(engine, false)?;
|
||||||
for item in carry {
|
for item in carry {
|
||||||
|
BIN
tests/ref/bugs/flow-5.png
Normal file
BIN
tests/ref/bugs/flow-5.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
13
tests/typ/bugs/flow-5.typ
Normal file
13
tests/typ/bugs/flow-5.typ
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// This bug caused an index-out-of-bounds panic when layouting paragraphs needed
|
||||||
|
// multiple reorderings.
|
||||||
|
|
||||||
|
---
|
||||||
|
#set page(height: 200pt)
|
||||||
|
#lorem(30)
|
||||||
|
|
||||||
|
#figure(placement: auto, block(height: 100%))
|
||||||
|
|
||||||
|
#lorem(10)
|
||||||
|
|
||||||
|
#lorem(10)
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user