]> git.eshelyaron.com Git - emacs.git/commitdiff
Protect bidi cache from inadvertent resets
authorEli Zaretskii <eliz@gnu.org>
Sun, 31 May 2020 14:34:09 +0000 (17:34 +0300)
committerEli Zaretskii <eliz@gnu.org>
Sun, 31 May 2020 14:34:09 +0000 (17:34 +0300)
* src/xdisp.c (Fline_pixel_height, Fmove_point_visually): Save and
restore the bidi cache, to avoid inadvertently resetting it by
starting a new iteration through buffer text.  This could cause
trouble if these functions are called during a redisplay cycle,
especially while we were processing RTL text.

src/xdisp.c

index db0ec683159c5e7fb7ed3dd7eb8f865db8ce5826..ea28395cf55ca77cdd60e66b21bd09cfcf7af0d8 100644 (file)
@@ -1415,6 +1415,7 @@ Value is the height in pixels of the line at point.  */)
       set_buffer_internal_1 (XBUFFER (w->contents));
     }
   SET_TEXT_POS (pt, PT, PT_BYTE);
+  void *itdata = bidi_shelve_cache ();
   start_display (&it, w, pt);
   /* Start from the beginning of the screen line, to make sure we
      traverse all of its display elements, and thus capture the
@@ -1426,6 +1427,7 @@ Value is the height in pixels of the line at point.  */)
   if (old_buffer)
     set_buffer_internal_1 (old_buffer);
 
+  bidi_unshelve_cache (itdata, false);
   return result;
 }
 
@@ -24442,6 +24444,7 @@ Value is the new character position of point.  */)
       bool at_eol_p;
       bool overshoot_expected = false;
       bool target_is_eol_p = false;
+      void *itdata = bidi_shelve_cache ();
 
       /* Setup the arena.  */
       SET_TEXT_POS (pt, PT, PT_BYTE);
@@ -24670,6 +24673,7 @@ Value is the new character position of point.  */)
 
       /* Move point to that position.  */
       SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it));
+      bidi_unshelve_cache (itdata, false);
     }
 
   return make_fixnum (PT);