diff options
| author | Eli Zaretskii | 2017-11-17 21:37:04 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2017-11-17 21:37:04 +0200 |
| commit | 90add182a4d7b42942722d6cffb1ca213e546a37 (patch) | |
| tree | 58e26597bda6a0086c5fa94071c528586159ee7b /src | |
| parent | 648c128b5f5eb8988aabcc2073b706d2561acd15 (diff) | |
| download | emacs-90add182a4d7b42942722d6cffb1ca213e546a37.tar.gz emacs-90add182a4d7b42942722d6cffb1ca213e546a37.zip | |
Prevent aborts in line-move-visual
* src/indent.c (line_number_display_width): Avoid assertion
violations in init_iterator when the window's buffer was
temporarily switched without updating window-start. (Bug#29326)
Diffstat (limited to 'src')
| -rw-r--r-- | src/indent.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/indent.c b/src/indent.c index 192eec72efe..5f931a511e4 100644 --- a/src/indent.c +++ b/src/indent.c | |||
| @@ -1959,21 +1959,26 @@ line_number_display_width (struct window *w, int *width, int *pixel_width) | |||
| 1959 | else | 1959 | else |
| 1960 | { | 1960 | { |
| 1961 | struct it it; | 1961 | struct it it; |
| 1962 | struct text_pos wstart; | 1962 | struct text_pos startpos; |
| 1963 | bool saved_restriction = false; | 1963 | bool saved_restriction = false; |
| 1964 | ptrdiff_t count = SPECPDL_INDEX (); | 1964 | ptrdiff_t count = SPECPDL_INDEX (); |
| 1965 | SET_TEXT_POS_FROM_MARKER (wstart, w->start); | 1965 | SET_TEXT_POS_FROM_MARKER (startpos, w->start); |
| 1966 | void *itdata = bidi_shelve_cache (); | 1966 | void *itdata = bidi_shelve_cache (); |
| 1967 | /* We must start from window's start point, but it could be | 1967 | /* We want to start from window's start point, but it could be |
| 1968 | outside the accessible region. */ | 1968 | outside the accessible region, in which case we widen the |
| 1969 | if (wstart.charpos < BEGV || wstart.charpos > ZV) | 1969 | buffer temporarily. It could even be beyond the buffer's end |
| 1970 | (Org mode's display of source code snippets is known to cause | ||
| 1971 | that), in which case we just punt and start from point instead. */ | ||
| 1972 | if (startpos.charpos > Z) | ||
| 1973 | SET_TEXT_POS (startpos, PT, PT_BYTE); | ||
| 1974 | if (startpos.charpos < BEGV || startpos.charpos > ZV) | ||
| 1970 | { | 1975 | { |
| 1971 | record_unwind_protect (save_restriction_restore, | 1976 | record_unwind_protect (save_restriction_restore, |
| 1972 | save_restriction_save ()); | 1977 | save_restriction_save ()); |
| 1973 | Fwiden (); | 1978 | Fwiden (); |
| 1974 | saved_restriction = true; | 1979 | saved_restriction = true; |
| 1975 | } | 1980 | } |
| 1976 | start_display (&it, w, wstart); | 1981 | start_display (&it, w, startpos); |
| 1977 | /* The call to move_it_by_lines below will not generate a line | 1982 | /* The call to move_it_by_lines below will not generate a line |
| 1978 | number if the first line shown in the window is hscrolled | 1983 | number if the first line shown in the window is hscrolled |
| 1979 | such that all of its display elements are out of view. So we | 1984 | such that all of its display elements are out of view. So we |