mirror of
https://github.com/typst/typst
synced 2025-05-16 18:15:29 +08:00
flush pending headers as soon as possible
- dont wait until the end of the region, as a header can start and end in the same region (i.e. never repeat).
This commit is contained in:
parent
054b3b89d1
commit
75403f86a9
@ -244,6 +244,7 @@ impl<'a> GridLayouter<'a> {
|
||||
if y >= footer.start {
|
||||
if y == footer.start {
|
||||
self.layout_footer(footer, engine, self.finished.len())?;
|
||||
self.flush_pending_headers();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@ -251,6 +252,11 @@ impl<'a> GridLayouter<'a> {
|
||||
|
||||
self.layout_row(y, engine, 0)?;
|
||||
|
||||
// After the first non-header row is placed, pending headers are no
|
||||
// longer orphans and can repeat, so we move them to repeating
|
||||
// headers.
|
||||
self.flush_pending_headers();
|
||||
|
||||
y += 1;
|
||||
}
|
||||
|
||||
|
@ -73,6 +73,14 @@ impl<'a> GridLayouter<'a> {
|
||||
)?
|
||||
}
|
||||
|
||||
// No chance of orphans as we're immediately placing conflicting
|
||||
// headers afterwards, which basically are not headers, for all intents
|
||||
// and purposes. It is therefore guaranteed that all new headers have
|
||||
// been placed at least once.
|
||||
if !conflicting_headers.is_empty() {
|
||||
self.flush_pending_headers();
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -122,6 +130,13 @@ impl<'a> GridLayouter<'a> {
|
||||
let [first_header, ..] = headers else {
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
// Should be impossible to have two consecutive chunks of pending
|
||||
// headers since they are always as long as possible, only being
|
||||
// interrupted by direct conflict between consecutive headers, in which
|
||||
// case we flush pending headers immediately.
|
||||
assert!(self.pending_headers.is_empty());
|
||||
|
||||
// Assuming non-conflicting headers sorted by increasing y, this must
|
||||
// be the header with the lowest level (sorted by increasing levels).
|
||||
let first_level = first_header.unwrap().level;
|
||||
|
Loading…
x
Reference in New Issue
Block a user