emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs-24 r117449: Fix bug #18276 with vertical motion thro


From: Eli Zaretskii
Subject: [Emacs-diffs] emacs-24 r117449: Fix bug #18276 with vertical motion through a display property.
Date: Mon, 18 Aug 2014 15:35:35 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 117449
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/18276
committer: Eli Zaretskii <address@hidden>
branch nick: emacs-24
timestamp: Mon 2014-08-18 18:34:49 +0300
message:
  Fix bug #18276 with vertical motion through a display property.
  
   src/indent.c (Fvertical_motion): Fix vertical motion up through a
   display property after a newline.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/indent.c                   indent.c-20091113204419-o5vbwnq5f7feedwu-181
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2014-08-17 14:48:50 +0000
+++ b/src/ChangeLog     2014-08-18 15:34:49 +0000
@@ -1,3 +1,8 @@
+2014-08-18  Eli Zaretskii  <address@hidden>
+
+       * indent.c (Fvertical_motion): Fix vertical motion up through a
+       display property after a newline.  (Bug#18276)
+
 2014-08-17  Eli Zaretskii  <address@hidden>
 
        * xdisp.c (display_line): Don't assume that the call to

=== modified file 'src/indent.c'
--- a/src/indent.c      2014-06-21 12:30:02 +0000
+++ b/src/indent.c      2014-08-18 15:34:49 +0000
@@ -2004,6 +2004,8 @@
       int first_x;
       bool overshoot_handled = 0;
       bool disp_string_at_start_p = 0;
+      ptrdiff_t nlines = XINT (lines);
+      int vpos_init = 0;
 
       itdata = bidi_shelve_cache ();
       SET_TEXT_POS (pt, PT, PT_BYTE);
@@ -2093,18 +2095,31 @@
 
          overshoot_handled = 1;
        }
-      if (XINT (lines) <= 0)
-       {
-         it.vpos = 0;
+      else if (IT_CHARPOS (it) == PT - 1
+              && FETCH_BYTE (PT - 1) == '\n'
+              && nlines < 0)
+       {
+         /* The position we started from was covered by a display
+            property, so we moved to position before the string, and
+            backed up one line, because the character at PT - 1 is a
+            newline.  So we need one less line to go up.  */
+         nlines++;
+         /* But we still need to record that one line, in order to
+            return the correct value to the caller.  */
+         vpos_init = -1;
+       }
+      if (nlines <= 0)
+       {
+         it.vpos = vpos_init;
          /* Do this even if LINES is 0, so that we move back to the
             beginning of the current line as we ought.  */
-         if (XINT (lines) == 0 || IT_CHARPOS (it) > 0)
-           move_it_by_lines (&it, max (PTRDIFF_MIN, XINT (lines)));
+         if (nlines == 0 || IT_CHARPOS (it) > 0)
+           move_it_by_lines (&it, max (PTRDIFF_MIN, nlines));
        }
       else if (overshoot_handled)
        {
          it.vpos = 0;
-         move_it_by_lines (&it, min (PTRDIFF_MAX, XINT (lines)));
+         move_it_by_lines (&it, min (PTRDIFF_MAX, nlines));
        }
       else
        {
@@ -2119,13 +2134,13 @@
                  it.vpos = 0;
                  move_it_by_lines (&it, 1);
                }
-             if (XINT (lines) > 1)
-               move_it_by_lines (&it, min (PTRDIFF_MAX, XINT (lines) - 1));
+             if (nlines > 1)
+               move_it_by_lines (&it, min (PTRDIFF_MAX, nlines - 1));
            }
          else
            {
              it.vpos = 0;
-             move_it_by_lines (&it, min (PTRDIFF_MAX, XINT (lines)));
+             move_it_by_lines (&it, min (PTRDIFF_MAX, nlines));
            }
        }
 


reply via email to

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