Try to avoid horizontal scrolling with wide insets.

There was a problem with end of paragraph markers. By design, wide insets choose their size without taking in account the marker. This should not lead to unneeded horizontal scrolling.

Part of ticket #9807.
This commit is contained in:
Jean-Marc Lasgouttes 2015-11-03 10:01:05 +01:00
parent 88d1c790b6
commit eb1e85b096

View File

@ -3045,7 +3045,7 @@ void BufferView::checkCursorScrollOffset(PainterInfo & pi)
int offset = d->horiz_scroll_offset_;
int const MARGIN = 2 * theFontMetrics(d->cursor_.real_current_font).em()
+ row.right_margin;
if (row.width() <= workWidth() - row.right_margin) {
if (row.right_x() <= workWidth() - row.right_margin) {
// Row is narrower than the work area, no offset needed.
offset = 0;
} else {
@ -3059,8 +3059,8 @@ void BufferView::checkCursorScrollOffset(PainterInfo & pi)
// Correct the offset to make sure that we do not scroll too much
if (offset < 0)
offset = 0;
if (row.width() - offset < workWidth() - row.right_margin)
offset = row.width() - workWidth() + row.right_margin;
if (row.right_x() - offset < workWidth() - row.right_margin)
offset = row.right_x() - workWidth() + row.right_margin;
}
//lyxerr << "cur_x=" << cur_x << ", offset=" << offset << ", row.wid=" << row.width() << ", margin=" << MARGIN << endl;