/* Estimate how many newlines we must move back. */
nlines = max (1, dy / default_line_pixel_height (it->w));
+ /* Move one line more back, for the (rare) situation where we have
+ bidi-reordered continued lines, and we start from the top-most
+ screen line, which is the last in logical order. */
+ if (it->bidi_p && dy == 0)
+ nlines++;
if (it->line_wrap == TRUNCATE || nchars_per_row == 0)
pos_limit = BEGV;
else
while (nlines-- && IT_CHARPOS (*it) > pos_limit)
back_to_previous_visible_line_start (it);
- /* Move one line more back, for the (rare) situation where we have
- bidi-reordered continued lines, and we start from the top-most
- screen line, which is the last in logical order. */
- if (it->bidi_p && dy == 0)
- back_to_previous_visible_line_start (it);
/* Reseat the iterator here. When moving backward, we don't want
reseat to skip forward over invisible text, set up the iterator
to deliver from overlay strings at the new position etc. So,
if (dy == 0)
{
+ /* Adjust nlines for increasing it at the beginning. */
+ nlines -= !!it->bidi_p;
/* DY == 0 means move to the start of the screen line. The
value of nlines is > 0 if continuation lines were involved,
or if the original IT position was at start of a line. */