From aff596127476c0fbcb11ccbbce63f32d03785653 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Fri, 5 Aug 2022 15:53:06 +0300 Subject: [PATCH] Avoid assertion violations in 'back_to_previous_visible_line_start' * src/xdisp.c (init_iterator): Always initialize narrowed_begv to zero, since SET_WITH_NARROWED_BEGV depends on it being non-zero as an indication that long-line optimizations are in use. (back_to_previous_visible_line_start): When long-line optimizations are in effect, we may end up not on a newline. --- src/xdisp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/xdisp.c b/src/xdisp.c index 099efed2db1..3ca0022a6d3 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -3473,8 +3473,9 @@ init_iterator (struct it *it, struct window *w, &it->bidi_it); } - if (current_buffer->long_line_optimizations_p) - it->narrowed_begv = 0; + /* This is set only when long_line_optimizations_p is non-zero + for the current buffer. */ + it->narrowed_begv = 0; /* Compute faces etc. */ reseat (it, it->current.pos, true); @@ -7412,7 +7413,7 @@ back_to_previous_visible_line_start (struct it *it) it->continuation_lines_width = 0; eassert (IT_CHARPOS (*it) >= BEGV); - eassert (it->narrowed_begv > BEGV + eassert (it->narrowed_begv > 0 /* long-line optimizations: all bets off */ || IT_CHARPOS (*it) == BEGV || FETCH_BYTE (IT_BYTEPOS (*it) - 1) == '\n'); CHECK_IT (it); -- 2.39.2