Fix C-n/C-p when a line starts with an image

* src/xdisp.c (move_it_to): Handle the case where the second call
to move_it_in_display_line_to under MOVE_TO_Y takes us farther
from TO_CHARPOS than the first call.  This fixes values returned
by pos-visible-in-window-p and posn-at-point when the screen line
starts with invisible text followed by an image.  (Bug#9092)
This commit is contained in:
Eli Zaretskii 2020-12-15 19:34:16 +02:00
parent adf968b998
commit 2e7402b760

View file

@ -9957,7 +9957,27 @@ move_it_to (struct it *it, ptrdiff_t to_charpos, int to_x, int to_y, int to_vpos
{
skip = skip2;
if (skip == MOVE_POS_MATCH_OR_ZV)
reached = 7;
{
reached = 7;
/* If the last move_it_in_display_line_to call
took us away from TO_CHARPOS, back up to the
previous position, as it is a better
approximation of TO_CHARPOS. (Note that we
could have both positions after TO_CHARPOS or
both positions before it, due to bidi
reordering.) */
if (IT_CHARPOS (*it) != to_charpos
&& ((IT_CHARPOS (it_backup) > to_charpos)
== (IT_CHARPOS (*it) > to_charpos)))
{
int max_ascent = it->max_ascent;
int max_descent = it->max_descent;
RESTORE_IT (it, &it_backup, backup_data);
it->max_ascent = max_ascent;
it->max_descent = max_descent;
}
}
}
}
else