[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs-26 5ee9ccf: Fix 'posn-at-point' when line numbers ar
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] emacs-26 5ee9ccf: Fix 'posn-at-point' when line numbers are displayed |
Date: |
Sat, 2 Jun 2018 05:24:50 -0400 (EDT) |
branch: emacs-26
commit 5ee9ccf5c9d3f0b863439ac815c03c7b3e33a288
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>
Fix 'posn-at-point' when line numbers are displayed
* src/xdisp.c (pos_visible_p): For the leftmost glyph, adjust the X
coordinate due to line-number display. (Bug#30834)
(cherry picked from commit 4a20174d7949028f66b18a92a75d6b74194242a8)
---
src/xdisp.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/src/xdisp.c b/src/xdisp.c
index 21fb6bc..6ca1150 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -1383,6 +1383,29 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int
*x, int *y,
move_it_to (&it, charpos, -1, it.last_visible_y - 1, -1,
(charpos >= 0 ? MOVE_TO_POS : 0) | MOVE_TO_Y);
+ /* Adjust for line numbers, if CHARPOS is at or beyond first_visible_x,
+ but we didn't yet produce the line-number glyphs. */
+ if (!NILP (Vdisplay_line_numbers)
+ && it.current_x >= it.first_visible_x
+ && IT_CHARPOS (it) == charpos
+ && !it.line_number_produced_p)
+ {
+ /* If the pixel width of line numbers was not yet known, compute
+ it now. This usually happens in the first display line of a
+ window. */
+ if (!it.lnum_pixel_width)
+ {
+ struct it it2;
+ void *it2data = NULL;
+
+ SAVE_IT (it2, it, it2data);
+ move_it_by_lines (&it, 1);
+ it2.lnum_pixel_width = it.lnum_pixel_width;
+ RESTORE_IT (&it, &it2, it2data);
+ }
+ it.current_x += it.lnum_pixel_width;
+ }
+
if (charpos >= 0
&& (((!it.bidi_p || it.bidi_it.scan_dir != -1)
&& IT_CHARPOS (it) >= charpos)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] emacs-26 5ee9ccf: Fix 'posn-at-point' when line numbers are displayed,
Eli Zaretskii <=