From d279e6680842b872ae3aab1fb429b1879db50f7f Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 5 Jan 2015 17:42:55 +0200 Subject: [PATCH] Fix assertion violations in try_window_id (Bug#19511) src/xdisp.c (move_it_to, try_cursor_movement): Don't use the window end information if the window_end_valid flag is unset. (try_window_id): If the call to display_line invalidated the window end information, give up the try_window_id optimization. --- src/ChangeLog | 8 ++++++++ src/xdisp.c | 19 ++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index d9dd53ba1df..acd7e729254 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2015-01-05 Eli Zaretskii + + * xdisp.c (move_it_to, try_cursor_movement): Don't use the window + end information if the window_end_valid flag is unset. + (try_window_id): If the call to display_line invalidated the + window end information, give up the try_window_id optimization. + (Bug#19511) + 2015-01-04 Eli Zaretskii * w32fns.c (Fx_server_version, Fx_server_vendor): Doc fix. diff --git a/src/xdisp.c b/src/xdisp.c index ebab8395a6c..a1cc286512b 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -9379,6 +9379,7 @@ move_it_to (struct it *it, ptrdiff_t to_charpos, int to_x, int to_y, int to_vpos && it->current_x == it->last_visible_x - 1 && it->c != '\n' && it->c != '\t' + && it->w->window_end_valid && it->vpos < it->w->window_end_vpos) { it->continuation_lines_width += it->current_x; @@ -15521,7 +15522,8 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_ste /* Likewise there was a check whether window_end_vpos is nil or larger than the window. Now window_end_vpos is int and so never nil, but let's leave eassert to check whether it fits in the window. */ - eassert (w->window_end_vpos < w->current_matrix->nrows); + eassert (!w->window_end_valid + || w->window_end_vpos < w->current_matrix->nrows); /* Handle case where text has not changed, only point, and it has not moved off the frame. */ @@ -18185,6 +18187,21 @@ try_window_id (struct window *w) if (f->fonts_changed) return -1; + /* The redisplay iterations in display_line above could have + triggered font-lock, which could have done something that + invalidates IT->w window's end-point information, on which we + rely below. E.g., one package, which will remain unnamed, used + to install a font-lock-fontify-region-function that called + bury-buffer, whose side effect is to switch the buffer displayed + by IT->w, and that predictably resets IT->w's window_end_valid + flag, which we already tested at the entry to this function. + Amply punish such packages/modes by giving up on this + optimization in those cases. */ + if (!w->window_end_valid) + { + clear_glyph_matrix (w->desired_matrix); + return -1; + } /* Compute differences in buffer positions, y-positions etc. for lines reused at the bottom of the window. Compute what we can -- 2.39.2