diff options
| author | Martin <mhaug@live.de> | 2021-06-27 17:08:40 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-27 17:08:40 +0200 |
| commit | 57bd3e23c79878d106ab8be17c71caca6c4f5a7c (patch) | |
| tree | 0eb5fd53d66299de17ac49a608e5aa44b6411aaf /src/layout/par.rs | |
| parent | 6b6cdae7ce95681d6a1194be70b375494166a8c6 (diff) | |
Apply suggestions from code review
Co-authored-by: Laurenz <laurmaedje@gmail.com>
Diffstat (limited to 'src/layout/par.rs')
| -rw-r--r-- | src/layout/par.rs | 16 |
1 files changed, 11 insertions, 5 deletions
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. |
