From 43a174f62c50871c0bcb6e4b15144a177f028218 Mon Sep 17 00:00:00 2001 From: Gregory Heytings Date: Sun, 31 Jul 2022 22:36:55 +0000 Subject: [PATCH] Move the computation of narrowing bounds for long line optimizations. * src/xdisp.c (init_iterator): Move the computation from here... (reseat): ... to here. Also recompute the position in certain cases. --- src/xdisp.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/xdisp.c b/src/xdisp.c index 88a489e290f..8a19b3bda97 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -3413,12 +3413,6 @@ init_iterator (struct it *it, struct window *w, } } - if (current_buffer->long_line_optimizations_p) - { - it->narrowed_begv = get_narrowed_begv (w, window_point (w)); - it->narrowed_zv = get_narrowed_zv (w, window_point (w)); - } - /* If a buffer position was specified, set the iterator there, getting overlays and face properties from that position. */ if (charpos >= BUF_BEG (current_buffer)) @@ -7532,6 +7526,17 @@ reseat (struct it *it, struct text_pos pos, bool force_p) reseat_1 (it, pos, false); + if (current_buffer->long_line_optimizations_p) + { + if (!it->narrowed_begv + || ((pos.charpos < it->narrowed_begv || pos.charpos > it->narrowed_zv) + && (!redisplaying_p || it->line_wrap == TRUNCATE))) + { + it->narrowed_begv = get_narrowed_begv (it->w, window_point (it->w)); + it->narrowed_zv = get_narrowed_zv (it->w, window_point (it->w)); + } + } + /* Determine where to check text properties. Avoid doing it where possible because text property lookup is very expensive. */ if (force_p -- 2.39.5