From d39a3da6f3df4ff3c08e5b68fe629e10d1b8f3ea Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Thu, 15 Aug 2013 18:20:03 +0300 Subject: [PATCH] Fix bug #15090 with redisplay under linum-mode and visual-line-mode. 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 | 9 +++++++++ src/xdisp.c | 20 +++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index 5131f666c6e..1a83531ad10 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2013-08-15 Eli Zaretskii + + * 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 * image.c (imagemagick_compute_animated_image): Implement animated diff --git a/src/xdisp.c b/src/xdisp.c index 4d0b0ab9974..8b72c58cd07 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -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. */ -- 2.11.4.GIT