Fix bug #11063 with move_it_by_lines when there's a before-string at bol.
authorEli Zaretskii <eliz@gnu.org>
Sat, 31 Mar 2012 19:30:53 +0000 (22:30 +0300)
committerEli Zaretskii <eliz@gnu.org>
Sat, 31 Mar 2012 19:30:53 +0000 (22:30 +0300)
 src/xdisp.c (move_it_by_lines): When DVPOS is positive, and the
 position we get to after a call to move_it_to fails the
 IS_POS_VALID_AFTER_MOVE_P test, move to the next buffer position
 only if we wind up in a string from display property.

src/ChangeLog
src/xdisp.c

index 33c93a3..9be289c 100644 (file)
@@ -1,5 +1,10 @@
 2012-03-31  Eli Zaretskii  <eliz@gnu.org>
 
+       * xdisp.c (move_it_by_lines): When DVPOS is positive, and the
+       position we get to after a call to move_it_to fails the
+       IS_POS_VALID_AFTER_MOVE_P test, move to the next buffer position
+       only if we wind up in a string from display property.  (Bug#11063)
+
        * window.c (Fdelete_other_windows_internal): Invalidate the row
        and column information about mouse highlight, so that redisplay
        restores it after reallocating the glyph matrices.  (Bug#7464)
index 54379a2..dcd14a1 100644 (file)
@@ -8973,7 +8973,20 @@ move_it_by_lines (struct it *it, int dvpos)
     {
       move_it_to (it, -1, -1, -1, it->vpos + dvpos, MOVE_TO_VPOS);
       if (!IT_POS_VALID_AFTER_MOVE_P (it))
-       move_it_to (it, IT_CHARPOS (*it) + 1, -1, -1, -1, MOVE_TO_POS);
+       {
+         /* Only move to the next buffer position if we ended up in a
+            string from display property, not in an overlay string
+            (before-string or after-string).  That is because the
+            latter don't conceal the underlying buffer position, so
+            we can ask to move the iterator to the exact position we
+            are interested in.  Note that, even if we are already at
+            IT_CHARPOS (*it), the call below is not a no-op, as it
+            will detect that we are at the end of the string, pop the
+            iterator, and compute it->current_x and it->hpos
+            correctly.  */
+         move_it_to (it, IT_CHARPOS (*it) + it->string_from_display_prop_p,
+                     -1, -1, -1, MOVE_TO_POS);
+       }
     }
   else
     {