summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2022-09-30 15:38:22 +0300
committerEli Zaretskii <eliz@gnu.org>2022-09-30 15:38:22 +0300
commit3553904a90a242b7ee7b48607ac02cf57e2ab753 (patch)
treee4757be7a9a13a08ee6d11186862af896974f05a
parent12a78711c94ccf5c46dd4e9653596c87b6fe0a18 (diff)
downloademacs-3553904a90a242b7ee7b48607ac02cf57e2ab753.tar.gz
emacs-3553904a90a242b7ee7b48607ac02cf57e2ab753.tar.bz2
emacs-3553904a90a242b7ee7b48607ac02cf57e2ab753.zip
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.
-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. */