diff src/redisplay.c @ 5783:cfc6a8c144f1

Don't return a Charbpos before visible region, start_with_line_at_pixpos() src/ChangeLog addition: 2014-01-21 Aidan Kehoe <kehoea@parhasard.net> * redisplay.c (start_with_line_at_pixpos): Apply Julian Bradfield's change of slrnlc7tnv.l3h.jcb@home.stevens-bradfield.com , never returning a Charbpos before the visible region. Thank you Julian!
author Aidan Kehoe <kehoea@parhasard.net>
date Tue, 21 Jan 2014 00:27:16 +0000
parents b6c506c30f93
children bd4d2c8ef9cc
line wrap: on
line diff
--- a/src/redisplay.c	Mon Jan 20 18:13:15 2014 +0000
+++ b/src/redisplay.c	Tue Jan 21 00:27:16 2014 +0000
@@ -8287,12 +8287,15 @@
       if (pixheight < 0)
 	{
 	  w->line_cache_validation_override--;
-	  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;
+          /* I see no reason why cur_pos can't be before BEGV
+             here, so check for it. It's not clear to me whether
+             prev_pos could be before BEGV, so check that as well. */
+          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 <= BUF_BEGV (b)) ? BUF_BEGV (b) : prev_pos;
+          else
+            return (cur_pos <= BUF_BEGV (b)) ? BUF_BEGV (b) : cur_pos;
 	}
 
       cur_elt--;