Reset right_boundary row property when row is shortened

Fixes bug #10003.
This commit is contained in:
Jean-Marc Lasgouttes 2016-03-07 13:46:13 +01:00
parent 869d34ddeb
commit 5f9053d6d3
3 changed files with 13 additions and 8 deletions

View File

@ -413,10 +413,10 @@ void Row::pop_back()
}
void Row::shortenIfNeeded(pos_type const keep, int const w)
bool Row::shortenIfNeeded(pos_type const keep, int const w)
{
if (empty() || width() <= w)
return;
return false;
Elements::iterator const beg = elements_.begin();
Elements::iterator const end = elements_.end();
@ -433,7 +433,7 @@ void Row::shortenIfNeeded(pos_type const keep, int const w)
if (cit == end) {
// This should not happen since the row is too long.
LYXERR0("Something is wrong cannot shorten row: " << *this);
return;
return false;
}
// Iterate backwards over breakable elements and try to break them
@ -476,7 +476,7 @@ void Row::shortenIfNeeded(pos_type const keep, int const w)
dim_.wid = wid_brk + brk.dim.wid;
// If there are other elements, they should be removed.
elements_.erase(cit_brk + 1, end);
return;
return true;
}
}
@ -493,7 +493,7 @@ void Row::shortenIfNeeded(pos_type const keep, int const w)
end_ = cit->pos;
dim_.wid = wid;
elements_.erase(cit, end);
return;
return true;
}
/* If we are here, it means that we have not found a separator to
@ -508,7 +508,9 @@ void Row::shortenIfNeeded(pos_type const keep, int const w)
dim_.wid = wid + cit->dim.wid;
// If there are other elements, they should be removed.
elements_.erase(next(cit, 1), end);
return true;
}
return false;
}

View File

@ -227,8 +227,9 @@ public:
* 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
* \return true if the row has been shortened.
*/
void shortenIfNeeded(pos_type const body_pos, int const width);
bool shortenIfNeeded(pos_type const body_pos, int const width);
/**
* If last element of the row is a string, compute its width

View File

@ -911,8 +911,10 @@ void TextMetrics::breakRow(Row & row, int const right_margin, pit_type const pit
row.addVirtual(end, docstring(1, char_type(0x00B6)), f, Change());
}
// if the row is too large, try to cut at last separator.
row.shortenIfNeeded(body_pos, width);
// 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))
row.right_boundary(false);
// make sure that the RTL elements are in reverse ordering
row.reverseRTL(is_rtl);