Fix breaking of MANUAL_LABEL paragraph when label is too long

Typical example is a Labeling layout which label is an inline equation
larger than the screen. Before this commit, the row would not get
broken at all.

Two parts in the patch:

1/ when breaking the row in shortenIfNeeded, mark the last element as
   AlwaysBreakAfter instead of BreakAfter, in case the next element is
   NoBreakBefore.

2/ when nothing could be done, as last resort keep the first element
   of the row only.
This commit is contained in:
Jean-Marc Lasgouttes 2022-01-23 20:55:18 +01:00
parent f8f86a1a81
commit 6c98ac5a7b

View File

@ -537,7 +537,7 @@ void moveElements(Row::Elements & from, Row::Elements::iterator const & it,
to.insert(to.end(), it, from.end());
from.erase(it, from.end());
if (!from.empty())
from.back().row_flags = (from.back().row_flags & ~AfterFlags) | BreakAfter;
from.back().row_flags = (from.back().row_flags & ~AfterFlags) | AlwaysBreakAfter;
}
}
@ -645,7 +645,9 @@ Row::Elements Row::shortenIfNeeded(int const w, int const next_width)
return tail;
}
return Elements();
// cit == beg; remove all elements after the first one.
moveElements(elements_, cit + 1, tail);
return tail;
}