[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-28 a22c9a3: Fix 'posn-at-point' near some overlays
From: |
Eli Zaretskii |
Subject: |
emacs-28 a22c9a3: Fix 'posn-at-point' near some overlays |
Date: |
Thu, 25 Nov 2021 08:07:06 -0500 (EST) |
branch: emacs-28
commit a22c9a34bd1cc3683b965383a59b4a50e9091776
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>
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)
---
src/xdisp.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/src/xdisp.c b/src/xdisp.c
index 34add80..4642541 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));
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-28 a22c9a3: Fix 'posn-at-point' near some overlays,
Eli Zaretskii <=