[LyX/master] Revert "Avoid row breaking at inconvenient places."

Jean-Marc Lasgouttes lasgouttes at lyx.org
Mon Sep 25 09:33:10 UTC 2023


commit 1ca43e1938e172e6f5a48eb353b0cb678b31f43d
Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
Date:   Mon Sep 25 12:28:01 2023 +0200

    Revert "Avoid row breaking at inconvenient places."
    
    The solution did create new issues.
    
    Fixes bug #12899.
    Unfixes bug #12660.
    
    This reverts commit f7de345f85b4a34346fc52b60a9e754b466d24f0.
---
 src/Row.cpp |   27 ++++-----------------------
 1 files changed, 4 insertions(+), 23 deletions(-)

diff --git a/src/Row.cpp b/src/Row.cpp
index a7f09e5..a7f00d5 100644
--- a/src/Row.cpp
+++ b/src/Row.cpp
@@ -602,31 +602,12 @@ Row::Elements Row::shortenIfNeeded(int const max_width, int const next_width)
 		 */
 		if (brk.splitAt(min(max_width - wid_brk, brk.dim.wid - 2), next_width, false, tail)) {
 			/* if this element originally did not cause a row overflow
-			 * in itself, and the next item is not breakable and would
-			 * still be too large after breaking, then we will have
-			 * issues in next row. Thus breaking does not help.
-			 *
-			 * FIXME: this is not perfect, since it is difficult to
-			 * know whether next element in tail is too large:
-			 *
-			 * - next element could be a very long word, which is
-			 *   theoretically breakable, but not in practice
-			 *   (difficult to solve).
-			 *
-			 * - next element could be short enough, but linked to
-			 *   another one with a NoBreak bond.
-			 *
-			 * Basically, it is difficult to solve that in a purely
-			 * left-to-right algorithm; implementing the TeX badness
-			 * algorithm is more difficult and more costly, so we do
-			 * our best in our restricted setting.
+			 * in itself, and the remainder of the row would still be
+			 * too large after breaking, then we will have issues in
+			 * next row. Thus breaking does not help.
 			 */
-			auto const cit_next = cit_brk + 1;
-			int const tail_wid = !tail.empty() ? tail.front().dim.wid : 0;
 			if (wid_brk + cit_brk->dim.wid < max_width
-			    && cit_next != elements_.end()
-			    && tail_wid + cit_next->dim.wid > next_width
-			    && !(cit_next->row_flags & CanBreakInside)) {
+			    && dim_.wid - (wid_brk + brk.dim.wid) >= next_width) {
 				tail.clear();
 				break;
 			}


More information about the lyx-cvs mailing list