commit cb3de88cc46125f461d5ed44956cfbac25f5a429
Author: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date:   Fri Jan 6 15:53:53 2023 +0100

    Fixup dcef1a9c: better handling of front-of-string splitting
    
    When splitting a string leads to a break before the first character, the
    best is to declare that splitting failed.
    
    Fixes bug #12617.
---
 src/Row.cpp |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/src/Row.cpp b/src/Row.cpp
index fea9a38..361ef96 100644
--- a/src/Row.cpp
+++ b/src/Row.cpp
@@ -144,8 +144,12 @@ bool Row::Element::splitAt(int const width, int 
next_width, bool force,
        FontMetrics::Breaks breaks = fm.breakString(str, width, next_width,
                                                 isRTL(), wrap_any | force);
 
-       // if breaking did not really work, give up
-       if (!force && breaks.front().nspc_wid > width) {
+       /** if breaking did not really work, give up
+        * case 1: we do not force break and the first element is longer than 
the limit;
+        * case 2: the first break occurs at the front of the string
+        */
+       if ((!force && breaks.front().nspc_wid > width)
+           || (breaks.size() > 1 && breaks.front().len == 0)) {
                if (dim.wid == 0)
                        dim.wid = fm.width(str);
                return false;
@@ -156,12 +160,6 @@ bool Row::Element::splitAt(int const width, int 
next_width, bool force,
        bool first = true;
        docstring::size_type i = 0;
        for (FontMetrics::Break const & brk : breaks) {
-               /* For some reason breakString can decide to break before the
-                * first character (normally we use a 0-width nbsp to prevent
-                * that). Skip leading empty elements, they are never wanted.
-                */
-               if (first && brk.len == 0 && breaks.size() > 1)
-                       continue;
                Element e(STRING, pos + i, font, change);
                e.str = str.substr(i, brk.len);
                e.endpos = e.pos + brk.len;
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to