Fix justification with hanging indent and negative spacing

Fixes #2419
This commit is contained in:
Laurenz 2023-10-28 20:05:32 +02:00
parent c3b1e32d11
commit aa62d05453
3 changed files with 15 additions and 3 deletions

View File

@ -1015,9 +1015,15 @@ fn linebreak_optimized<'a>(vt: &Vt, p: &'a Preparation<'a>, width: Abs) -> Vec<L
// The line is overfull. This is the case if
// - justification is on, but we'd need to shrink too much
// - justification is off and the line just doesn't fit
// Since any longer line will also be overfull, we can deactivate
// this breakpoint.
active = i + 1;
//
// If this is the earliest breakpoint in the active set
// (active == i), remove it from the active set. If there is an
// earlier one (active < i), then the logically shorter line was
// in fact longer (can happen with negative spacing) and we
// can't trim the active set just yet.
if active == i {
active += 1;
}
MAX_COST
} else if mandatory || eof {
// This is a mandatory break and the line is not overfull, so

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1,6 @@
// Test that combination of justification and hanging indent doesn't result in
// an underfull first line.
---
#set par(hanging-indent: 2.5cm, justify: true)
#lorem(5)