]> git.lyx.org Git - features.git/commitdiff
Remove 'premature optimization' that proved buggy
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 3 Jan 2018 17:28:55 +0000 (18:28 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 30 Jan 2018 10:06:30 +0000 (11:06 +0100)
At some time it seemed like a good idea in breakRow() to return early
when the row was bound to be empty. It turns out that this creates two
symptoms:

* empty paragraphs will not have an end of paragraph marker

* since row width is not correctly computed in this case, caret ghosts
  can appear in master.

This commit removes the oprimization and replace the do {} while()
construct to a straightforward while() {}.

Related to bug #10952.

(cherry picked from commit 76f0a3dd4ee5c7958c6dea79628ef8c2ac2c59bd)

src/TextMetrics.cpp

index 6c5a3222772cf794f6bc31fa27327477e951f3cc..620514421b78e9764be8eab39d66875379a15383 100644 (file)
@@ -834,11 +834,6 @@ bool TextMetrics::breakRow(Row & row, int const right_margin) const
        // the width available for the row.
        int const width = max_width_ - row.right_margin;
 
-       if (pos >= end || row.width() > width) {
-               row.endpos(end);
-               return need_new_row;
-       }
-
 #if 0
        //FIXME: As long as leftMargin() is not correctly implemented for
        // MARGIN_RIGHT_ADDRESS_BOX, we should also not do this here.
@@ -857,10 +852,7 @@ bool TextMetrics::breakRow(Row & row, int const right_margin) const
        // or the end of the par, then build a representation of the row.
        pos_type i = pos;
        FontIterator fi = FontIterator(*this, par, row.pit(), pos);
-       do {
-               // this can happen for an empty row after a newline
-               if (i >= end)
-                       break;
+       while (i < end && row.width() <= width) {
                char_type c = par.getChar(i);
                // The most special cases are handled first.
                if (par.isInset(i)) {
@@ -942,7 +934,7 @@ bool TextMetrics::breakRow(Row & row, int const right_margin) const
 
                ++i;
                ++fi;
-       } while (i < end && row.width() <= width);
+       }
        row.finalizeLast();
        row.endpos(i);