From: Eli Zaretskii Date: Fri, 30 Sep 2022 12:38:22 +0000 (+0300) Subject: Fix some issues with vertical-motion in bidi-reordered text X-Git-Tag: emacs-29.0.90~1856^2~129 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=3553904a90a242b7ee7b48607ac02cf57e2ab753;p=emacs.git Fix some issues with vertical-motion in bidi-reordered text This fixes some uses of vertical-motion when a screen line starts withcharacters of directionality that is opposite to the current paragraph's base direction. * src/xdisp.c (move_it_vertically_backward): Adjust NLINES to compensate for its increasing when DY == 0. --- 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. */