[LyX/master] Fix breaking of MANUAL_LABEL paragraph when label is too long

Jean-Marc Lasgouttes lasgouttes at lyx.org
Sun Jan 23 19:50:40 UTC 2022


commit 6c98ac5a7b63606333672969b7b23cbc42f6b57d
Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
Date:   Sun Jan 23 20:55:18 2022 +0100

    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.
---
 src/Row.cpp |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/Row.cpp b/src/Row.cpp
index d1921a6..f2d4aaf 100644
--- a/src/Row.cpp
+++ b/src/Row.cpp
@@ -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;
 }
 
 


More information about the lyx-cvs mailing list