diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-10-28 20:05:32 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-10-28 20:05:51 +0200 |
| commit | aa62d054532e91f988c39dee97c00ce54f18b605 (patch) | |
| tree | bf80b01bb972f1f30a34a0f2e3382e1f1da82348 /crates | |
| parent | c3b1e32d11c8485194070710431b081c52a64c45 (diff) | |
Fix justification with hanging indent and negative spacing
Fixes #2419
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/typst-library/src/layout/par.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/crates/typst-library/src/layout/par.rs b/crates/typst-library/src/layout/par.rs index ee47b579..9255124e 100644 --- a/crates/typst-library/src/layout/par.rs +++ b/crates/typst-library/src/layout/par.rs @@ -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 |
