Fixup 71d9f6e9: swap two tests to avoid line breaking issues

The new approach to line breaking introduced in 71d9f6e9 is correct,
but the newly introduced min_row_wid should not be updated when the
remaining line width after a break is larger than next_width.

Swapping the two tests fixes remaining issues.

Fixes (for good?) #12899.
This commit is contained in:
Jean-Marc Lasgouttes 2024-02-28 11:27:52 +01:00
parent 8f61b0859c
commit 677a2c2cd1

View File

@ -605,14 +605,6 @@ Row::Elements Row::shortenIfNeeded(int const max_width, int const next_width)
*/
int const split_width = min(max_width - wid_brk, brk.dim.wid - 2);
if (brk.splitAt(split_width, next_width, BEST_EFFORT, tail)) {
// if we did not manage to fit a part of the element into
// the split_width limit, at least remember that we can
// shorten the row if needed.
if (brk.dim.wid > split_width) {
min_row_wid = wid_brk + brk.dim.wid;
tail.clear();
continue;
}
/* if this element originally did not cause a row overflow
* in itself, and the remainder of the row would still be
* too large after breaking, then we will have issues in
@ -623,6 +615,15 @@ Row::Elements Row::shortenIfNeeded(int const max_width, int const next_width)
tail.clear();
break;
}
/* if we did not manage to fit a part of the element into
* the split_width limit, at least remember that we can
* shorten the row if needed.
*/
if (brk.dim.wid > split_width) {
min_row_wid = wid_brk + brk.dim.wid;
tail.clear();
continue;
}
// We have found a proper place where to break this string element.
end_ = brk.endpos;
*cit_brk = brk;