From e5615ce02d2507025c0ef51e79f232f89703b7cc Mon Sep 17 00:00:00 2001 From: Laurenz Date: Mon, 19 Sep 2022 10:42:54 +0200 Subject: [PATCH] Fix cost if last line is justified --- src/library/text/par.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/library/text/par.rs b/src/library/text/par.rs index 38240b3d..6c5c9765 100644 --- a/src/library/text/par.rs +++ b/src/library/text/par.rs @@ -780,16 +780,12 @@ fn linebreak_optimized<'a>( // this breakpoint. active = i + 1; MAX_COST - } else if eof { - // This is the final line and its not overfull since then we - // would have taken the above branch. - 0.0 - } else if mandatory { + } else if mandatory || eof { // This is a mandatory break and the line is not overfull, so it // has minimum cost. All breakpoints before this one become // inactive since no line can span above the mandatory break. active = k; - MIN_COST + MIN_COST + if attempt.justify { ratio.powi(3).abs() } else { 0.0 } } else { // Normal line with cost of |ratio^3|. ratio.powi(3).abs()