From: Eli Zaretskii Date: Thu, 16 Nov 2023 09:22:58 +0000 (+0200) Subject: Fix scrolling when continuation line starts with a display string X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=6733f45383bc1f57860d98803391cda076ed7cbb;p=emacs.git Fix scrolling when continuation line starts with a display string * src/xdisp.c (start_display): Compute continuation_lines_width for starting display in strings and images as well. (Bug#67201) --- diff --git a/src/xdisp.c b/src/xdisp.c index 041c7adfc50..2dbe85f0f04 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -3766,18 +3766,25 @@ start_display (struct it *it, struct window *w, struct text_pos pos) /* Don't reseat to previous visible line start if current start position is in a string or image. */ - if (it->method == GET_FROM_BUFFER && it->line_wrap != TRUNCATE) + if (it->line_wrap != TRUNCATE) { - int first_y = it->current_y; + enum it_method method = it->method; - /* If window start is not at a line start, skip forward to POS to - get the correct continuation lines width. */ + /* If window start is not at a line start, skip forward to POS + from the beginning of physical line to get the correct + continuation lines width. */ bool start_at_line_beg_p = (CHARPOS (pos) == BEGV || FETCH_BYTE (BYTEPOS (pos) - 1) == '\n'); if (!start_at_line_beg_p) { + int first_y = it->current_y; + int continuation_width; + void *itdata = NULL; + struct it it2; int new_x; + if (method != GET_FROM_BUFFER) + SAVE_IT (it2, *it, itdata); reseat_at_previous_visible_line_start (it); move_it_to (it, CHARPOS (pos), -1, -1, -1, MOVE_TO_POS); @@ -3824,6 +3831,17 @@ start_display (struct it *it, struct window *w, struct text_pos pos) else if (it->current.dpvec_index >= 0) it->current.dpvec_index = 0; + continuation_width = it->continuation_lines_width; + /* If we started from a position in something other than a + buffer, restore the original iterator state, keeping only + the continuation_lines_width, since we could now be very + far from the original position. */ + if (method != GET_FROM_BUFFER) + { + RESTORE_IT (it, &it2, itdata); + it->continuation_lines_width = continuation_width; + } + /* We're starting a new display line, not affected by the height of the continued line, so clear the appropriate fields in the iterator structure. */