From 57bd3e23c79878d106ab8be17c71caca6c4f5a7c Mon Sep 17 00:00:00 2001 From: Martin Date: Sun, 27 Jun 2021 17:08:40 +0200 Subject: Apply suggestions from code review Co-authored-by: Laurenz --- src/layout/incremental.rs | 2 +- src/layout/par.rs | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'src/layout') diff --git a/src/layout/incremental.rs b/src/layout/incremental.rs index e1d1ffba..953b76be 100644 --- a/src/layout/incremental.rs +++ b/src/layout/incremental.rs @@ -101,7 +101,7 @@ pub struct FramesEntry { /// How nested the frame was in the context is was originally appearing in. pub level: usize, /// How much the element was accessed during the last five compilations, the - /// most current one being the last element. `None` variants indicate that + /// most recent one being the last element. `None` variants indicate that /// the element is younger than five compilations. temperature: [Option; 5], } diff --git a/src/layout/par.rs b/src/layout/par.rs index 0cf1cd23..40cb84f2 100644 --- a/src/layout/par.rs +++ b/src/layout/par.rs @@ -219,12 +219,18 @@ impl<'a> ParLayouter<'a> { stack.finish_region(ctx); } - if !stack.regions.current.height.fits(line.size.height) - && stack.regions.in_full_last() - { - stack.overflowing = true; + // If the line does not fit vertically, we start a new region. + while !stack.regions.current.height.fits(line.size.height) { + if stack.regions.in_full_last() { + stack.overflowing = true; + break; + } + + stack.constraints.max.vertical.set_min( + stack.full.height - stack.regions.current.height + line.size.height, + ); + stack.finish_region(ctx); } - // If the line does not fit horizontally or we have a mandatory // line break (i.e. due to "\n"), we push the line into the // stack. -- cgit v1.2.3