# HG changeset patch # User Chong Yidong # Date 1226017747 0 # Node ID b33ed5d6e18f91be26462a611d6f3b9266c34d83 # Parent ba5206ebe3ffcea037f336f92a0b1d13655f5a1c (try_window_reusing_current_matrix): Ensure that window cursor position is valid after scrolling. diff -r ba5206ebe3ff -r b33ed5d6e18f src/xdisp.c --- a/src/xdisp.c Fri Nov 07 00:28:31 2008 +0000 +++ b/src/xdisp.c Fri Nov 07 00:29:07 2008 +0000 @@ -14393,13 +14393,6 @@ 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 @@ 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);