]> git.lyx.org Git - lyx.git/commitdiff
Fixup 71d9f6e9: swap two tests to avoid line breaking issues
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 28 Feb 2024 10:27:52 +0000 (11:27 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 29 Feb 2024 09:46:26 +0000 (10:46 +0100)
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.

src/Row.cpp

index 20a05c3bae832003f7a03870f68464a5e7e11238..86b4e5014ca80dd69a4f63c8eb459f161107c242 100644 (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;