summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/xdisp.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index 1f6f35e6c0a..55e74a36037 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -10709,6 +10709,11 @@ move_it_vertically_backward (struct it *it, int dy)
/* 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
@@ -10720,11 +10725,6 @@ move_it_vertically_backward (struct it *it, int dy)
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,
@@ -10775,6 +10775,8 @@ move_it_vertically_backward (struct it *it, int dy)
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. */