The new code should feel a bit more natural. It avoids explicit pixel values for the margins and does not scroll in some cases where it is not necessary.
#include "Language.h"
#include "LaTeXFeatures.h"
#include "LayoutFile.h"
#include "Language.h"
#include "LaTeXFeatures.h"
#include "LayoutFile.h"
#include "Lexer.h"
#include "LyX.h"
#include "LyXAction.h"
#include "Lexer.h"
#include "LyX.h"
#include "LyXAction.h"
// Horizontal scroll offset of the cursor row in pixels
int offset = d->horiz_scroll_offset_;
// Horizontal scroll offset of the cursor row in pixels
int offset = d->horiz_scroll_offset_;
+ int const MARGIN = Length(2, Length::EM).inPixels(workWidth());
if (cur_x < offset + MARGIN) {
// scroll right
offset = cur_x - MARGIN;
} else if (cur_x > offset + workWidth() - MARGIN) {
// scroll left
offset = cur_x - workWidth() + MARGIN;
if (cur_x < offset + MARGIN) {
// scroll right
offset = cur_x - MARGIN;
} else if (cur_x > offset + workWidth() - MARGIN) {
// scroll left
offset = cur_x - workWidth() + MARGIN;
- } else if(offset > 0
- && row.width() - offset < workWidth()){
- offset = row.width() - workWidth();
- if (offset != d->horiz_scroll_offset_)
- LYXERR0("Offset is now " << offset);
+ if (offset < 0 || row.width() <= workWidth())
+ offset = 0;
if (d->update_strategy_ == NoScreenUpdate
&& (offset != d->horiz_scroll_offset_
if (d->update_strategy_ == NoScreenUpdate
&& (offset != d->horiz_scroll_offset_