{
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