changeset 111101:f4fc1590d904

Fix L2R code using bug #1220 as a test case. xdisp.c (mouse_face_from_buffer_pos): before_string and after_string are also relevant when they come from an overlay.
author Eli Zaretskii <eliz@gnu.org>
date Sat, 28 Aug 2010 12:32:44 +0300
parents 5a930b6b595e
children 9fbc584102c2
files src/ChangeLog src/xdisp.c
diffstat 2 files changed, 17 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Sat Aug 21 18:24:15 2010 +0300
+++ b/src/ChangeLog	Sat Aug 28 12:32:44 2010 +0300
@@ -1,3 +1,8 @@
+2010-08-28  Eli Zaretskii  <eliz@gnu.org>
+
+	* xdisp.c (mouse_face_from_buffer_pos): Fix code using bug#1220 as
+	test case.
+
 2010-08-21  Eli Zaretskii  <eliz@gnu.org>
 
 	* xdisp.c (mouse_face_from_buffer_pos): Support mouse highlight in
--- a/src/xdisp.c	Sat Aug 21 18:24:15 2010 +0300
+++ b/src/xdisp.c	Sat Aug 28 12:32:44 2010 +0300
@@ -23897,7 +23897,7 @@
 	 between START_CHARPOS and END_CHARPOS, and highlight all the
 	 glyphs between those two.  This may cover more than just the
 	 text between START_CHARPOS and END_CHARPOS if the range of
-	 characters strides the the bidi level boundary, e.g. if the
+	 characters strides the bidi level boundary, e.g. if the
 	 beginning is in R2L text while the end is in L2R text or vice
 	 versa.  */
       if (!row->reversed_p)
@@ -23929,18 +23929,21 @@
 	    {
 	      /* BEFORE_STRING or AFTER_STRING are only relevant if
 		 they are present at buffer positions between
-		 START_CHARPOS and END_CHARPOS.  */
+		 START_CHARPOS and END_CHARPOS, or if they come from
+		 an overlay.  */
 	      if (EQ (glyph->object, before_string))
 		{
 		  pos = string_buffer_position (w, before_string,
 						start_charpos);
-		  if (pos && pos >= start_charpos && pos < end_charpos)
+		  /* If pos == 0, it means before_string came from an
+		     overlay, not from a buffer position.  */
+		  if (!pos || pos >= start_charpos && pos < end_charpos)
 		    break;
 		}
 	      else if (EQ (glyph->object, after_string))
 		{
 		  pos = string_buffer_position (w, after_string, end_charpos);
-		  if (pos && pos >= start_charpos && pos < end_charpos)
+		  if (!pos || pos >= start_charpos && pos < end_charpos)
 		    break;
 		}
 	      x += glyph->pixel_width;
@@ -24001,19 +24004,19 @@
 		      && end->charpos < end_charpos));
 	   --end)
 	{
-	  /* BEFORE_STRING or AFTER_STRING are only relevant if
-	     they are present at buffer positions between
-	     START_CHARPOS and END_CHARPOS.  */
+	  /* BEFORE_STRING or AFTER_STRING are only relevant if they
+	     are present at buffer positions between START_CHARPOS and
+	     END_CHARPOS, or if they come from an overlay.  */
 	  if (EQ (end->object, before_string))
 	    {
 	      pos = string_buffer_position (w, before_string, start_charpos);
-	      if (pos && pos >= start_charpos && pos < end_charpos)
+	      if (!pos || pos >= start_charpos && pos < end_charpos)
 		break;
 	    }
 	  else if (EQ (end->object, after_string))
 	    {
 	      pos = string_buffer_position (w, after_string, end_charpos);
-	      if (pos && pos >= start_charpos && pos < end_charpos)
+	      if (!pos || pos >= start_charpos && pos < end_charpos)
 		break;
 	    }
 	}