]> git.eshelyaron.com Git - emacs.git/commitdiff
Start fixing cursor motion around invisible text.
authorEli Zaretskii <eliz@gnu.org>
Sat, 2 Jul 2011 15:16:27 +0000 (18:16 +0300)
committerEli Zaretskii <eliz@gnu.org>
Sat, 2 Jul 2011 15:16:27 +0000 (18:16 +0300)
Hit a MAJOR design problem in pushing and popping bidi iterator state.

 src/xdisp.c (reseat_1): Call bidi_init_it to resync the bidi
 iterator with IT's position.
 (handle_stop, back_to_previous_visible_line_start, reseat_1):
 Reset the from_disp_prop_p flag.
 src/bidi.c (bidi_cache_search): Don't assume bidi_cache_last_idx is
 always valid if bidi_cache_idx is valid.
 (bidi_cache_find_level_change): xassert that bidi_cache_last_idx
 is valid if it's going to be used.

src/ChangeLog
src/bidi.c
src/xdisp.c

index c2da733feb1b17e332c8e3080a08a0efcba8a2ee..1a443e848a7a9cda9e04e3f89f7a75effa880534 100644 (file)
@@ -1,5 +1,15 @@
 2011-07-02  Eli Zaretskii  <eliz@gnu.org>
 
+       * xdisp.c (reseat_1): Call bidi_init_it to resync the bidi
+       iterator with IT's position.
+       (handle_stop, back_to_previous_visible_line_start, reseat_1):
+       Reset the from_disp_prop_p flag.
+
+       * bidi.c (bidi_cache_search): Don't assume bidi_cache_last_idx is
+       always valid if bidi_cache_idx is valid.
+       (bidi_cache_find_level_change): xassert that bidi_cache_last_idx
+       is valid if it's going to be used.
+
        * dispextern.h (struct iterator_stack_entry, struct it): New
        member from_disp_prop_p.
 
index 87978058a5b60ae981ab1cc9be44af7db976e0ad..05c16a70f9419a882638f55d58afc69d39bbf2c1 100644 (file)
@@ -352,8 +352,10 @@ bidi_cache_search (EMACS_INT charpos, int level, int dir)
 {
   int i, i_start;
 
-  if (bidi_cache_idx)
+  if (bidi_cache_idx > bidi_cache_start)
     {
+      if (bidi_cache_last_idx == -1)
+       bidi_cache_last_idx = bidi_cache_idx - 1;
       if (charpos < bidi_cache[bidi_cache_last_idx].charpos)
        {
          dir = -1;
@@ -418,6 +420,8 @@ bidi_cache_find_level_change (int level, int dir, int before)
       int i = dir ? bidi_cache_last_idx : bidi_cache_idx - 1;
       int incr = before ? 1 : 0;
 
+      xassert (!dir || bidi_cache_last_idx >= 0);
+
       if (!dir)
        dir = -1;
       else if (!incr)
index 7c1b2051e57a84f3c15842e5f66b5b21fbe7dcba..c3d5fd9479b95699ee982a2816fcabd5b9dac06e 100644 (file)
@@ -2915,6 +2915,7 @@ handle_stop (struct it *it)
                {
                  it->ignore_overlay_strings_at_pos_p = 1;
                  it->string_from_display_prop_p = 0;
+                 it->from_disp_prop_p = 0;
                  handle_overlay_change_p = 0;
                }
              handled = HANDLED_RECOMPUTE_PROPS;
@@ -5542,6 +5543,7 @@ back_to_previous_visible_line_start (struct it *it)
        --IT_BYTEPOS (it2);
        it2.sp = 0;
        it2.string_from_display_prop_p = 0;
+       it2.from_disp_prop_p = 0;
        if (handle_display_prop (&it2) == HANDLED_RETURN
            && !NILP (val = get_char_property_and_overlay
                      (make_number (pos), Qdisplay, Qnil, &overlay))
@@ -5740,12 +5742,13 @@ reseat_1 (struct it *it, struct text_pos pos, int set_stop_p)
   it->multibyte_p = !NILP (BVAR (current_buffer, enable_multibyte_characters));
   it->sp = 0;
   it->string_from_display_prop_p = 0;
+  it->from_disp_prop_p = 0;
   it->face_before_selective_p = 0;
   if (it->bidi_p)
     {
-      it->bidi_it.first_elt = 1;
+      bidi_init_it (IT_CHARPOS (*it), IT_BYTEPOS (*it), FRAME_WINDOW_P (it->f),
+                   &it->bidi_it);
       it->bidi_it.paragraph_dir = NEUTRAL_DIR;
-      it->bidi_it.disp_pos = -1;
       it->bidi_it.string.s = NULL;
       it->bidi_it.string.lstring = Qnil;
       it->bidi_it.string.bufpos = 0;