changeset 99424:b33ed5d6e18f

(try_window_reusing_current_matrix): Ensure that window cursor position is valid after scrolling.
author Chong Yidong <cyd@stupidchicken.com>
date Fri, 07 Nov 2008 00:29:07 +0000
parents ba5206ebe3ff
children 5a18dca9c353
files src/xdisp.c
diffstat 1 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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);