]> git.lyx.org Git - features.git/commitdiff
Change the way the element's width is updated.
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sat, 17 Jul 2021 21:16:15 +0000 (23:16 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 23 Nov 2021 15:31:30 +0000 (16:31 +0100)
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
src/TextMetrics.cpp

index 705a147389eec047f4516a0262e24e2936c3e55e..3bc8ef0d519f4462f7df692f68c39825ca8abb76 100644 (file)
@@ -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;
 }
 
 
index b5ba9746b998fa39ec2c443284659329090f518a..fa855e448e4573dfaff8661b872268e622844322 100644 (file)
@@ -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