diff src/redisplay.c @ 42:8b8b7f3559a2 r19-15b104

Import from CVS: tag r19-15b104
author cvs
date Mon, 13 Aug 2007 08:54:51 +0200
parents e04119814345
children 56c54cf7c5b6
line wrap: on
line diff
--- a/src/redisplay.c	Mon Aug 13 08:54:26 2007 +0200
+++ b/src/redisplay.c	Mon Aug 13 08:54:51 2007 +0200
@@ -6635,7 +6635,8 @@
 {
   struct buffer *b = XBUFFER (w->buffer);
   int cur_elt;
-  Bufpos cur_pos;
+  Bufpos cur_pos, prev_pos = point;
+  int point_line_height;
   int pixheight = pixpos - WINDOW_TEXT_TOP (w);
 
   validate_line_start_cache (w);
@@ -6645,6 +6646,9 @@
   /* #### See comment in update_line_start_cache about big minibuffers. */
   if (cur_elt < 0)
     return point;
+
+  point_line_height = Dynarr_atp (w->line_start_cache, cur_elt)->height;
+
   while (1)
     {
       cur_pos = Dynarr_atp (w->line_start_cache, cur_elt)->start;
@@ -6656,7 +6660,12 @@
       if (pixheight < 0)
 	{
 	  w->line_cache_validation_override--;
-	  return cur_pos;
+	  if (-pixheight > point_line_height)
+	    /* We can't make the target line cover pixpos, so put it
+	       above pixpos.  That way it will at least be visible. */
+	    return prev_pos;  
+	  else
+	    return cur_pos;
 	}
 
       cur_elt--;
@@ -6682,6 +6691,7 @@
 	  cur_elt = point_in_line_start_cache (w, cur_pos, 2) - 1;
 	  assert (cur_elt >= 0);
 	}
+      prev_pos = cur_pos;
     }
 }