emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r105308: Fix pos-visible-in-window-p


From: Eli Zaretskii
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r105308: Fix pos-visible-in-window-p under bidi redisplay.
Date: Sat, 23 Jul 2011 13:46:21 +0300
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 105308 [merge]
committer: Eli Zaretskii <address@hidden>
branch nick: trunk
timestamp: Sat 2011-07-23 13:46:21 +0300
message:
  Fix pos-visible-in-window-p under bidi redisplay.
  
   src/xdisp.c (move_it_in_display_line_to): Record the best matching
   position for TO_CHARPOS while scanning the line, and restore it on
   exit if none of the characters scanned was an exact match.  Fixes
   vertical-motion and pos-visible-in-window-p under bidi redisplay
   when exact match is impossible due to invisible text, and the
   lines are truncated.
modified:
  src/ChangeLog
  src/xdisp.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2011-07-23 08:33:06 +0000
+++ b/src/ChangeLog     2011-07-23 10:46:21 +0000
@@ -1,3 +1,12 @@
+2011-07-23  Eli Zaretskii  <address@hidden>
+
+       * xdisp.c (move_it_in_display_line_to): Record the best matching
+       position for TO_CHARPOS while scanning the line, and restore it on
+       exit if none of the characters scanned was an exact match.  Fixes
+       vertical-motion and pos-visible-in-window-p under bidi redisplay
+       when exact match is impossible due to invisible text, and the
+       lines are truncated.
+
 2011-07-23  Jan Djärv  <address@hidden>
 
        * nsterm.m (initFrameFromEmacs): Set NSTitledWindowMask in styleMask

=== modified file 'src/xdisp.c'
--- a/src/xdisp.c       2011-07-23 07:42:56 +0000
+++ b/src/xdisp.c       2011-07-23 10:46:21 +0000
@@ -7641,8 +7641,9 @@
 {
   enum move_it_result result = MOVE_UNDEFINED;
   struct glyph_row *saved_glyph_row;
-  struct it wrap_it, atpos_it, atx_it;
+  struct it wrap_it, atpos_it, atx_it, ppos_it;
   void *wrap_data = NULL, *atpos_data = NULL, *atx_data = NULL;
+  void *ppos_data = NULL;
   int may_wrap = 0;
   enum it_method prev_method = it->method;
   EMACS_INT prev_pos = IT_CHARPOS (*it);
@@ -7661,6 +7662,19 @@
   atpos_it.sp = -1;
   atx_it.sp = -1;
 
+  /* Use ppos_it under bidi reordering to save a copy of IT for the
+     position > CHARPOS that is the closest to CHARPOS.  We restore
+     that position in IT when we have scanned the entire display line
+     without finding a match for CHARPOS and all the character
+     positions are greater than CHARPOS.  */
+  if (it->bidi_p)
+    {
+      SAVE_IT (ppos_it, *it, ppos_data);
+      SET_TEXT_POS (ppos_it.current.pos, ZV, ZV_BYTE);
+      if ((op & MOVE_TO_POS) && IT_CHARPOS (*it) >= to_charpos)
+       SAVE_IT (ppos_it, *it, ppos_data);
+    }
+
 #define BUFFER_POS_REACHED_P()                                 \
   ((op & MOVE_TO_POS) != 0                                     \
    && BUFFERP (it->object)                                     \
@@ -7786,6 +7800,11 @@
          if (IT_CHARPOS (*it) < CHARPOS (this_line_min_pos))
            SET_TEXT_POS (this_line_min_pos,
                          IT_CHARPOS (*it), IT_BYTEPOS (*it));
+         if (it->bidi_p
+             && (op & MOVE_TO_POS)
+             && IT_CHARPOS (*it) > to_charpos
+             && IT_CHARPOS (*it) < IT_CHARPOS (ppos_it))
+           SAVE_IT (ppos_it, *it, ppos_data);
          continue;
        }
 
@@ -7996,7 +8015,11 @@
          if ((op & MOVE_TO_POS) != 0
              && !saw_smaller_pos
              && IT_CHARPOS (*it) > to_charpos)
-           result = MOVE_POS_MATCH_OR_ZV;
+           {
+             result = MOVE_POS_MATCH_OR_ZV;
+             if (it->bidi_p && IT_CHARPOS (ppos_it) < ZV)
+               RESTORE_IT (it, &ppos_it, ppos_data);
+           }
          else
            result = MOVE_NEWLINE_OR_CR;
          break;
@@ -8012,6 +8035,11 @@
        SET_TEXT_POS (this_line_min_pos, IT_CHARPOS (*it), IT_BYTEPOS (*it));
       if (IT_CHARPOS (*it) < to_charpos)
        saw_smaller_pos = 1;
+      if (it->bidi_p
+         && (op & MOVE_TO_POS)
+         && IT_CHARPOS (*it) >= to_charpos
+         && IT_CHARPOS (*it) < IT_CHARPOS (ppos_it))
+       SAVE_IT (ppos_it, *it, ppos_data);
 
       /* Stop if lines are truncated and IT's current x-position is
         past the right edge of the window now.  */
@@ -8021,7 +8049,9 @@
          if (!FRAME_WINDOW_P (it->f)
              || IT_OVERFLOW_NEWLINE_INTO_FRINGE (it))
            {
-             if (!get_next_display_element (it)
+             int at_eob_p = 0;
+
+             if ((at_eob_p = !get_next_display_element (it))
                  || BUFFER_POS_REACHED_P ()
                  /* If we are past TO_CHARPOS, but never saw any
                     character positions smaller than TO_CHARPOS,
@@ -8032,6 +8062,8 @@
                      && IT_CHARPOS (*it) > to_charpos))
                {
                  result = MOVE_POS_MATCH_OR_ZV;
+                 if (it->bidi_p && !at_eob_p && IT_CHARPOS (ppos_it) < ZV)
+                   RESTORE_IT (it, &ppos_it, ppos_data);
                  break;
                }
              if (ITERATOR_AT_END_OF_LINE_P (it))
@@ -8045,6 +8077,8 @@
                   && IT_CHARPOS (*it) > to_charpos)
            {
              result = MOVE_POS_MATCH_OR_ZV;
+             if (it->bidi_p && IT_CHARPOS (ppos_it) < ZV)
+               RESTORE_IT (it, &ppos_it, ppos_data);
              break;
            }
          result = MOVE_LINE_TRUNCATED;
@@ -8070,6 +8104,8 @@
     xfree (atx_data);
   if (wrap_data)
     xfree (wrap_data);
+  if (ppos_data)
+    xfree (ppos_data);
 
   /* Restore the iterator settings altered at the beginning of this
      function.  */


reply via email to

[Prev in Thread] Current Thread [Next in Thread]