diff options
| author | Eli Zaretskii | 2017-07-03 18:57:01 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2017-07-03 18:57:01 +0300 |
| commit | 52bfb7d4d6595302b5261ff810951e0b3281352c (patch) | |
| tree | 0ce66e5db8fff172a6843af2666dbbf58bf3e267 /src | |
| parent | 4c9353a5840b285631a86a5bad2b48ea6276abf3 (diff) | |
| download | emacs-52bfb7d4d6595302b5261ff810951e0b3281352c.tar.gz emacs-52bfb7d4d6595302b5261ff810951e0b3281352c.zip | |
Avoid errors in vertical-motion when buffer is narrowed
* src/indent.c (Fvertical_motion): If need to start from
window-start, and it is outside of the accessible portion,
temporarily widen the buffer. This avoids errors in evil-mode.
Reported by James Nguyen <james@jojojames.com>.
Diffstat (limited to 'src')
| -rw-r--r-- | src/indent.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/indent.c b/src/indent.c index 2cacfbbe3c0..70351f90466 100644 --- a/src/indent.c +++ b/src/indent.c | |||
| @@ -2077,11 +2077,24 @@ whether or not it is currently displayed in some window. */) | |||
| 2077 | && !EQ (Vdisplay_line_numbers, Qvisual)) | 2077 | && !EQ (Vdisplay_line_numbers, Qvisual)) |
| 2078 | { | 2078 | { |
| 2079 | struct text_pos wstart; | 2079 | struct text_pos wstart; |
| 2080 | bool saved_restriction = false; | ||
| 2081 | ptrdiff_t count1 = SPECPDL_INDEX (); | ||
| 2080 | SET_TEXT_POS_FROM_MARKER (wstart, w->start); | 2082 | SET_TEXT_POS_FROM_MARKER (wstart, w->start); |
| 2081 | itdata = bidi_shelve_cache (); | 2083 | itdata = bidi_shelve_cache (); |
| 2084 | /* We must start from window's start point, but it could be | ||
| 2085 | outside the accessible region. */ | ||
| 2086 | if (wstart.charpos < BEGV || wstart.charpos > ZV) | ||
| 2087 | { | ||
| 2088 | record_unwind_protect (save_restriction_restore, | ||
| 2089 | save_restriction_save ()); | ||
| 2090 | Fwiden (); | ||
| 2091 | saved_restriction = true; | ||
| 2092 | } | ||
| 2082 | start_display (&it, w, wstart); | 2093 | start_display (&it, w, wstart); |
| 2083 | move_it_by_lines (&it, 1); | 2094 | move_it_by_lines (&it, 1); |
| 2084 | lnum_width = it.lnum_width; | 2095 | lnum_width = it.lnum_width; |
| 2096 | if (saved_restriction) | ||
| 2097 | unbind_to (count1, Qnil); | ||
| 2085 | bidi_unshelve_cache (itdata, 0); | 2098 | bidi_unshelve_cache (itdata, 0); |
| 2086 | } | 2099 | } |
| 2087 | SET_TEXT_POS (pt, PT, PT_BYTE); | 2100 | SET_TEXT_POS (pt, PT, PT_BYTE); |