]> git.eshelyaron.com Git - emacs.git/commitdiff
Move the computation of narrowing bounds for long line optimizations.
authorGregory Heytings <gregory@heytings.org>
Sun, 31 Jul 2022 22:36:55 +0000 (22:36 +0000)
committerGregory Heytings <gregory@heytings.org>
Sun, 31 Jul 2022 22:38:48 +0000 (00:38 +0200)
* src/xdisp.c (init_iterator): Move the computation from here...
(reseat): ... to here.  Also recompute the position in certain cases.

src/xdisp.c

index 88a489e290f6ed8d9e6a74e2a0a814598ae4b06b..8a19b3bda97f18d3cbf90ce1300b9732098a647f 100644 (file)
@@ -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