Fix bug #15090 with redisplay under linum-mode and visual-line-mode.
authorEli Zaretskii <eliz@gnu.org>
Thu, 15 Aug 2013 15:20:03 +0000 (18:20 +0300)
committerEli Zaretskii <eliz@gnu.org>
Thu, 15 Aug 2013 15:20:03 +0000 (18:20 +0300)
 src/xdisp.c (compute_window_start_on_continuation_line): When
 WORD_WRAP is in effect, use move_it_to instead of move_it_by_lines
 to make sure we end up setting the window start at the leftmost
 visible character of the display line.  This avoids funky
 horizontal shifting because the window start is not kept on the
 same position.

src/ChangeLog
src/xdisp.c

index 5131f66..1a83531 100644 (file)
@@ -1,3 +1,12 @@
+2013-08-15  Eli Zaretskii  <eliz@gnu.org>
+
+       * xdisp.c (compute_window_start_on_continuation_line): When
+       WORD_WRAP is in effect, use move_it_to instead of move_it_by_lines
+       to make sure we end up setting the window start at the leftmost
+       visible character of the display line.  This avoids funky
+       horizontal shifting because the window start is not kept on the
+       same position.  (Bug#15090)
+
 2013-08-15  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
        * image.c (imagemagick_compute_animated_image): Implement animated
index 4d0b0ab..8b72c58 100644 (file)
@@ -14912,7 +14912,25 @@ compute_window_start_on_continuation_line (struct window *w)
            {
              min_distance = distance;
              pos = it.current.pos;
-             move_it_by_lines (&it, 1);
+             if (it.line_wrap == WORD_WRAP)
+               {
+                 /* Under WORD_WRAP, move_it_by_lines is likely to
+                    overshoot and stop not at the first, but the
+                    second character from the left margin.  So in
+                    that case, we need a more tight control on the X
+                    coordinate of the iterator than move_it_by_lines
+                    promises in its contract.  The method is to first
+                    go to the last (rightmost) visible character of a
+                    line, then move to the leftmost character on the
+                    next line in a separate call.  */
+                 move_it_to (&it, ZV, it.last_visible_x, it.current_y, -1,
+                             MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y);
+                 move_it_to (&it, ZV, 0,
+                             it.current_y + it.max_ascent + it.max_descent, -1,
+                             MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y);
+               }
+             else
+               move_it_by_lines (&it, 1);
            }
 
          /* Set the window start there.  */