fix footer layout order and consecutive footer pushing

This commit is contained in:
PgBiel 2025-06-13 01:41:29 -03:00
parent 8c416b88f2
commit 858e620ef7
2 changed files with 19 additions and 3 deletions

View File

@ -1600,12 +1600,20 @@ impl<'a> GridLayouter<'a> {
// //
// Use index for iteration to avoid borrow conflict. // Use index for iteration to avoid borrow conflict.
// //
// Note that repeating footers are in reverse order.
//
// TODO(subfooters): "pending footers" vector for footers we're // TODO(subfooters): "pending footers" vector for footers we're
// about to place. Needed for widow prevention of non-repeated // about to place. Needed for widow prevention of non-repeated
// footers. // footers.
let mut i = 0; let mut i = 0;
while let Some(footer) = self.repeating_footers.get(i) { while let Some(footer_index) = self.repeating_footers.len().checked_sub(1 + i)
self.layout_footer(footer, false, engine, self.finished.len())?; {
self.layout_footer(
self.repeating_footers[footer_index],
false,
engine,
self.finished.len(),
)?;
i += 1; i += 1;
} }
} }

View File

@ -550,9 +550,17 @@ impl<'a> GridLayouter<'a> {
return Ok(()); return Ok(());
} }
// Collect upcoming consecutive footers, they will start repeating with
// this one if compatible
let mut min_level = next_footer.level;
let first_conflicting_index = other_footers let first_conflicting_index = other_footers
.iter() .iter()
.take_while(|f| f.level > next_footer.level) .take_while(|f| {
// TODO(subfooters): check for short-lived
let compatible = f.repeated && f.level > min_level;
min_level = f.level;
compatible
})
.count() .count()
+ 1; + 1;