diff --git a/src/Row.cpp b/src/Row.cpp index 58a23805f2..ba1a5aa9bb 100644 --- a/src/Row.cpp +++ b/src/Row.cpp @@ -110,7 +110,6 @@ pos_type Row::Element::x2pos(int &x) const } //lyxerr << "=> p=" << pos + i << " x=" << x << endl; return pos + i; - } @@ -413,7 +412,7 @@ void Row::pop_back() } -bool Row::shortenIfNeeded(pos_type const keep, int const w) +bool Row::shortenIfNeeded(pos_type const keep, int const w, int const next_width) { if (empty() || width() <= w) return false; @@ -460,7 +459,7 @@ bool Row::shortenIfNeeded(pos_type const keep, int const w) * next row. Thus breaking does not help. */ if (wid_brk + cit_brk->dim.wid < w - && dim_.wid - (wid_brk + brk.dim.wid) >= w) { + && dim_.wid - (wid_brk + brk.dim.wid) >= next_width) { break; } end_ = brk.endpos; diff --git a/src/Row.h b/src/Row.h index 0bd4597746..b35c976083 100644 --- a/src/Row.h +++ b/src/Row.h @@ -230,10 +230,11 @@ public: * separator and update endpos if necessary. If all that * remains is a large word, cut it to \param width. * \param body_pos minimum amount of text to keep. - * \param width maximum width of the row + * \param width maximum width of the row. + * \param available width on next row. * \return true if the row has been shortened. */ - bool shortenIfNeeded(pos_type const body_pos, int const width); + bool shortenIfNeeded(pos_type const body_pos, int const width, int const next_width); /** * If last element of the row is a string, compute its width diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index c537e4536b..dbe1f6370d 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -933,7 +933,9 @@ void TextMetrics::breakRow(Row & row, int const right_margin, pit_type const pit // if the row is too large, try to cut at last separator. In case // of success, reset indication that the row was broken abruptly. - if (row.shortenIfNeeded(body_pos, width)) + int const next_width = max_width_ - leftMargin(max_width_, row.pit(), row.endpos()) + - rightMargin(row.pit()); + if (row.shortenIfNeeded(body_pos, width, next_width)) row.right_boundary(!row.empty() && row.back().endpos == row.endpos()); // make sure that the RTL elements are in reverse ordering diff --git a/status.22x b/status.22x index 5c969b2bf6..23deeb493e 100644 --- a/status.22x +++ b/status.22x @@ -161,6 +161,9 @@ What's new - Fix cursor movement when the document contains high-plane Unicode characters (bug 10443). +- Fix wrong on-screen text layout where a word would be alone on a + line. + - Fix crash when the document contains Unicode line-breaking characters. - Allow using colors supported by xcolor inside mathed (bug 10417).