diff options
| author | Eli Zaretskii | 2018-03-16 19:15:33 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2018-06-02 12:23:49 +0300 |
| commit | 5ee9ccf5c9d3f0b863439ac815c03c7b3e33a288 (patch) | |
| tree | de8776764505b36b5bd3e8f37089df74c86e67e0 /src | |
| parent | c4db7662bb4740f069e494cfe632c76a0d21d6d7 (diff) | |
| download | emacs-5ee9ccf5c9d3f0b863439ac815c03c7b3e33a288.tar.gz emacs-5ee9ccf5c9d3f0b863439ac815c03c7b3e33a288.zip | |
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)
Diffstat (limited to 'src')
| -rw-r--r-- | src/xdisp.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index 21fb6bca1d1..6ca115087c3 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, | |||
| 1383 | move_it_to (&it, charpos, -1, it.last_visible_y - 1, -1, | 1383 | move_it_to (&it, charpos, -1, it.last_visible_y - 1, -1, |
| 1384 | (charpos >= 0 ? MOVE_TO_POS : 0) | MOVE_TO_Y); | 1384 | (charpos >= 0 ? MOVE_TO_POS : 0) | MOVE_TO_Y); |
| 1385 | 1385 | ||
| 1386 | /* Adjust for line numbers, if CHARPOS is at or beyond first_visible_x, | ||
| 1387 | but we didn't yet produce the line-number glyphs. */ | ||
| 1388 | if (!NILP (Vdisplay_line_numbers) | ||
| 1389 | && it.current_x >= it.first_visible_x | ||
| 1390 | && IT_CHARPOS (it) == charpos | ||
| 1391 | && !it.line_number_produced_p) | ||
| 1392 | { | ||
| 1393 | /* If the pixel width of line numbers was not yet known, compute | ||
| 1394 | it now. This usually happens in the first display line of a | ||
| 1395 | window. */ | ||
| 1396 | if (!it.lnum_pixel_width) | ||
| 1397 | { | ||
| 1398 | struct it it2; | ||
| 1399 | void *it2data = NULL; | ||
| 1400 | |||
| 1401 | SAVE_IT (it2, it, it2data); | ||
| 1402 | move_it_by_lines (&it, 1); | ||
| 1403 | it2.lnum_pixel_width = it.lnum_pixel_width; | ||
| 1404 | RESTORE_IT (&it, &it2, it2data); | ||
| 1405 | } | ||
| 1406 | it.current_x += it.lnum_pixel_width; | ||
| 1407 | } | ||
| 1408 | |||
| 1386 | if (charpos >= 0 | 1409 | if (charpos >= 0 |
| 1387 | && (((!it.bidi_p || it.bidi_it.scan_dir != -1) | 1410 | && (((!it.bidi_p || it.bidi_it.scan_dir != -1) |
| 1388 | && IT_CHARPOS (it) >= charpos) | 1411 | && IT_CHARPOS (it) >= charpos) |