diff options
| author | Eli Zaretskii | 2017-07-02 18:01:39 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2017-07-02 18:01:39 +0300 |
| commit | 4c9353a5840b285631a86a5bad2b48ea6276abf3 (patch) | |
| tree | cab569e2b2ed396ca5258c33a5b29ecf20fee73c /src | |
| parent | b5ce3100a8549df519d6f2b577fe7c3acf90cb40 (diff) | |
| download | emacs-4c9353a5840b285631a86a5bad2b48ea6276abf3.tar.gz emacs-4c9353a5840b285631a86a5bad2b48ea6276abf3.zip | |
Avoid off-by-one errors in column C-n/C-p calculations
* src/indent.c (Fvertical_motion): Help C-n/C-p estimate correctly
the width used up by line numbers by looking near the window-start
point.
Diffstat (limited to 'src')
| -rw-r--r-- | src/indent.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/indent.c b/src/indent.c index adecc3622a8..2cacfbbe3c0 100644 --- a/src/indent.c +++ b/src/indent.c | |||
| @@ -2068,9 +2068,26 @@ whether or not it is currently displayed in some window. */) | |||
| 2068 | start_x = window_column_x (w, window, start_col, cur_col); | 2068 | start_x = window_column_x (w, window, start_col, cur_col); |
| 2069 | } | 2069 | } |
| 2070 | 2070 | ||
| 2071 | itdata = bidi_shelve_cache (); | 2071 | /* When displaying line numbers, we need to prime IT's |
| 2072 | lnum_width with the value calculated at window's start, since | ||
| 2073 | that's what normal window redisplay does. Otherwise C-n/C-p | ||
| 2074 | will sometimes err by one column. */ | ||
| 2075 | int lnum_width = 0; | ||
| 2076 | if (!NILP (Vdisplay_line_numbers) | ||
| 2077 | && !EQ (Vdisplay_line_numbers, Qvisual)) | ||
| 2078 | { | ||
| 2079 | struct text_pos wstart; | ||
| 2080 | SET_TEXT_POS_FROM_MARKER (wstart, w->start); | ||
| 2081 | itdata = bidi_shelve_cache (); | ||
| 2082 | start_display (&it, w, wstart); | ||
| 2083 | move_it_by_lines (&it, 1); | ||
| 2084 | lnum_width = it.lnum_width; | ||
| 2085 | bidi_unshelve_cache (itdata, 0); | ||
| 2086 | } | ||
| 2072 | SET_TEXT_POS (pt, PT, PT_BYTE); | 2087 | SET_TEXT_POS (pt, PT, PT_BYTE); |
| 2088 | itdata = bidi_shelve_cache (); | ||
| 2073 | start_display (&it, w, pt); | 2089 | start_display (&it, w, pt); |
| 2090 | it.lnum_width = lnum_width; | ||
| 2074 | first_x = it.first_visible_x; | 2091 | first_x = it.first_visible_x; |
| 2075 | it_start = IT_CHARPOS (it); | 2092 | it_start = IT_CHARPOS (it); |
| 2076 | 2093 | ||