From: Chong Yidong Date: Fri, 7 Nov 2008 00:29:07 +0000 (+0000) Subject: (try_window_reusing_current_matrix): Ensure that window cursor X-Git-Tag: emacs-pretest-23.0.90~1936 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=4a240b947eede312708308dd72c6f0e1c27d811b;p=emacs.git (try_window_reusing_current_matrix): Ensure that window cursor position is valid after scrolling. --- diff --git a/src/xdisp.c b/src/xdisp.c index 7814bac5195..ee5ecbab447 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -14393,13 +14393,6 @@ try_window_reusing_current_matrix (w) if (display_line (&it)) last_text_row = it.glyph_row - 1; - /* Give up If point isn't in a row displayed or reused. */ - if (w->cursor.vpos < 0) - { - clear_glyph_matrix (w->desired_matrix); - return 0; - } - /* If point is in a reused row, adjust y and vpos of the cursor position. */ if (pt_row) @@ -14408,6 +14401,16 @@ try_window_reusing_current_matrix (w) w->cursor.y -= first_reusable_row->y - start_row->y; } + /* Give up if point isn't in a row displayed or reused. (This + also handles the case where w->cursor.vpos < nrows_scrolled + after the calls to display_line, which can happen with scroll + margins. See bug#1295.) */ + if (w->cursor.vpos < 0) + { + clear_glyph_matrix (w->desired_matrix); + return 0; + } + /* Scroll the display. */ run.current_y = first_reusable_row->y; run.desired_y = WINDOW_HEADER_LINE_HEIGHT (w);