]> git.lyx.org Git - features.git/commitdiff
Fix breaking of MANUAL_LABEL paragraph when label is too long
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sun, 23 Jan 2022 19:55:18 +0000 (20:55 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sun, 23 Jan 2022 20:21:25 +0000 (21:21 +0100)
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.

src/Row.cpp

index d1921a6d3fed15b5af7e0e65d5a608fbaf6892c0..f2d4aafe85be45993ff7322888a994354a5b068f 100644 (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;
 }