commit 890fcc08729fea5b1b8e6dba7f0e27d1e266c3aa
Author: Jean-Marc Lasgouttes <[email protected]>
Date:   Sat Jul 17 23:16:15 2021 +0200

    Change the way the element's width is updated.
    
    Remove the code that computed the width every 30 characters (yay!).
    Make sure that finalizeLast() is called after inserting a row element in
    a row in breakParagraph.
---
 src/Row.cpp         |   15 +++------------
 src/TextMetrics.cpp |    1 +
 2 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/src/Row.cpp b/src/Row.cpp
index 705a147..3bc8ef0 100644
--- a/src/Row.cpp
+++ b/src/Row.cpp
@@ -370,8 +370,7 @@ void Row::finalizeLast()
        if (elt.change.changed())
                changebar_ = true;
 
-       if (elt.type == STRING) {
-               dim_.wid -= elt.dim.wid;
+       if (elt.type == STRING && elt.dim.wid == 0) {
                elt.dim.wid = theFontMetrics(elt.font).width(elt.str);
                dim_.wid += elt.dim.wid;
        }
@@ -401,16 +400,8 @@ void Row::add(pos_type const pos, char_type const c,
                e.row_flags = can_break ? CanBreakInside : Inline;
                elements_.push_back(e);
        }
-       if (back().str.length() % 30 == 0) {
-               dim_.wid -= back().dim.wid;
-               back().str += c;
-               back().endpos = pos + 1;
-               back().dim.wid = theFontMetrics(back().font).width(back().str);
-               dim_.wid += back().dim.wid;
-       } else {
-               back().str += c;
-               back().endpos = pos + 1;
-       }
+       back().str += c;
+       back().endpos = pos + 1;
 }
 
 
diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index b5ba974..fa855e4 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -1092,6 +1092,7 @@ RowList TextMetrics::breakParagraph(Row const & bigrow) 
const
                                                    
!elt.font.language()->wordWrap());
                // a new element in the row
                rows.back().push_back(elt);
+               rows.back().finalizeLast();
                pos = elt.endpos;
 
                // Go to next element
-- 
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to