From: Eli Zaretskii Date: Thu, 25 Nov 2021 13:06:08 +0000 (+0200) Subject: Fix 'posn-at-point' near some overlays X-Git-Tag: emacs-28.0.90~37 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a22c9a34bd1cc3683b965383a59b4a50e9091776;p=emacs.git Fix 'posn-at-point' near some overlays * src/xdisp.c (pos_visible_p): Fix 'posn-at-point' for positions just after a display property that draws a fringe bitmap. (Bug#52097) --- diff --git a/src/xdisp.c b/src/xdisp.c index 34add807986..4642541823c 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -1992,7 +1992,17 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y, } *x = top_x; - *y = max (top_y + max (0, it.max_ascent - it.ascent), window_top_y); + /* The condition below is a heuristic fix for the situation + where move_it_to stops just after finishing the display + of a fringe bitmap, which resets it.ascent to zero, and + thus causes Y to be offset by it.max_ascent. */ + if (it.ascent == 0 && it.what == IT_IMAGE + && it.method != GET_FROM_IMAGE + && it.image_id < 0 + && it.max_ascent > 0) + *y = max (top_y, window_top_y); + else + *y = max (top_y + max (0, it.max_ascent - it.ascent), window_top_y); *rtop = max (0, window_top_y - top_y); *rbot = max (0, bottom_y - it.last_visible_y); *rowh = max (0, (min (bottom_y, it.last_visible_y) @@ -2020,7 +2030,13 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y, RESTORE_IT (&it2, &it2, it2data); move_it_to (&it2, charpos, -1, -1, -1, MOVE_TO_POS); *x = it2.current_x; - *y = it2.current_y + it2.max_ascent - it2.ascent; + if (it2.ascent == 0 && it2.what == IT_IMAGE + && it2.method != GET_FROM_IMAGE + && it2.image_id < 0 + && it2.max_ascent > 0) + *y = it2.current_y; + else + *y = it2.current_y + it2.max_ascent - it2.ascent; *rtop = max (0, -it2.current_y); *rbot = max (0, ((it2.current_y + it2.max_ascent + it2.max_descent) - it.last_visible_y));