diff options
| author | Eli Zaretskii | 2018-03-16 19:15:33 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2018-03-16 19:15:33 +0200 |
| commit | 4a20174d7949028f66b18a92a75d6b74194242a8 (patch) | |
| tree | e9fb5dd70e7e446aa22727d0108eff32f9553d88 /src | |
| parent | 33cba5405c724566673cf023513bfb1faa963bea (diff) | |
| download | emacs-4a20174d7949028f66b18a92a75d6b74194242a8.tar.gz emacs-4a20174d7949028f66b18a92a75d6b74194242a8.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)
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 424f1735b5c..a97d4db6070 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -1381,6 +1381,29 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y, | |||
| 1381 | move_it_to (&it, charpos, -1, it.last_visible_y - 1, -1, | 1381 | move_it_to (&it, charpos, -1, it.last_visible_y - 1, -1, |
| 1382 | (charpos >= 0 ? MOVE_TO_POS : 0) | MOVE_TO_Y); | 1382 | (charpos >= 0 ? MOVE_TO_POS : 0) | MOVE_TO_Y); |
| 1383 | 1383 | ||
| 1384 | /* Adjust for line numbers, if CHARPOS is at or beyond first_visible_x, | ||
| 1385 | but we didn't yet produce the line-number glyphs. */ | ||
| 1386 | if (!NILP (Vdisplay_line_numbers) | ||
| 1387 | && it.current_x >= it.first_visible_x | ||
| 1388 | && IT_CHARPOS (it) == charpos | ||
| 1389 | && !it.line_number_produced_p) | ||
| 1390 | { | ||
| 1391 | /* If the pixel width of line numbers was not yet known, compute | ||
| 1392 | it now. This usually happens in the first display line of a | ||
| 1393 | window. */ | ||
| 1394 | if (!it.lnum_pixel_width) | ||
| 1395 | { | ||
| 1396 | struct it it2; | ||
| 1397 | void *it2data = NULL; | ||
| 1398 | |||
| 1399 | SAVE_IT (it2, it, it2data); | ||
| 1400 | move_it_by_lines (&it, 1); | ||
| 1401 | it2.lnum_pixel_width = it.lnum_pixel_width; | ||
| 1402 | RESTORE_IT (&it, &it2, it2data); | ||
| 1403 | } | ||
| 1404 | it.current_x += it.lnum_pixel_width; | ||
| 1405 | } | ||
| 1406 | |||
| 1384 | if (charpos >= 0 | 1407 | if (charpos >= 0 |
| 1385 | && (((!it.bidi_p || it.bidi_it.scan_dir != -1) | 1408 | && (((!it.bidi_p || it.bidi_it.scan_dir != -1) |
| 1386 | && IT_CHARPOS (it) >= charpos) | 1409 | && IT_CHARPOS (it) >= charpos) |