emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs-24 r116947: Fix bug #17244 with line-move-visual whe


From: Eli Zaretskii
Subject: [Emacs-diffs] emacs-24 r116947: Fix bug #17244 with line-move-visual when display string covers a lot of text.
Date: Sat, 12 Apr 2014 11:22:59 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 116947
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/17244
committer: Eli Zaretskii <address@hidden>
branch nick: emacs-24
timestamp: Sat 2014-04-12 14:21:47 +0300
message:
  Fix bug #17244 with line-move-visual when display string covers a lot of text.
  
   src/xdisp.c (move_it_by_lines): If a large portion of buffer text is
   covered by a display string that ends in a newline, and that cases
   going back by DVPOS lines to hit the search limit, lift the limit
   and go back until DVPOS is reached.
   src/indent.c (Fvertical_motion): Handle correctly the case when the
   display string is preceded by an empty line.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/indent.c                   indent.c-20091113204419-o5vbwnq5f7feedwu-181
  src/xdisp.c                    xdisp.c-20091113204419-o5vbwnq5f7feedwu-240
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2014-04-11 08:11:57 +0000
+++ b/src/ChangeLog     2014-04-12 11:21:47 +0000
@@ -1,3 +1,13 @@
+2014-04-12  Eli Zaretskii  <address@hidden>
+
+       * xdisp.c (move_it_by_lines): If a large portion of buffer text is
+       covered by a display string that ends in a newline, and that cases
+       going back by DVPOS lines to hit the search limit, lift the limit
+       and go back until DVPOS is reached.  (Bug#17244)
+
+       * indent.c (Fvertical_motion): Handle correctly the case when the
+       display string is preceded by an empty line.
+
 2014-04-11  Eli Zaretskii  <address@hidden>
 
        * w32.c (sys_umask) <WRITE_USER>: Remove redundant constant, and

=== modified file 'src/indent.c'
--- a/src/indent.c      2014-01-29 18:04:11 +0000
+++ b/src/indent.c      2014-04-12 11:21:47 +0000
@@ -2051,8 +2051,15 @@
           string, move_it_to will overshoot it, while vertical-motion
           wants to put the cursor _before_ the display string.  So in
           that case, we move to buffer position before the display
-          string, and avoid overshooting.  */
-       move_it_to (&it, disp_string_at_start_p ? PT - 1 : PT,
+          string, and avoid overshooting.  But if the position before
+          the display string is a newline, we don't do this, because
+          otherwise we will end up in a screen line that is one too
+          far back.  */
+       move_it_to (&it,
+                   (!disp_string_at_start_p
+                    || FETCH_BYTE (IT_BYTEPOS (it)) == '\n')
+                   ? PT
+                   : PT - 1,
                    -1, -1, -1, MOVE_TO_POS);
 
       /* IT may move too far if truncate-lines is on and PT lies

=== modified file 'src/xdisp.c'
--- a/src/xdisp.c       2014-03-23 15:57:25 +0000
+++ b/src/xdisp.c       2014-04-12 11:21:47 +0000
@@ -9511,6 +9511,7 @@
       ptrdiff_t start_charpos, i;
       int nchars_per_row
        = (it->last_visible_x - it->first_visible_x) / FRAME_COLUMN_WIDTH 
(it->f);
+      bool hit_pos_limit = false;
       ptrdiff_t pos_limit;
 
       /* Start at the beginning of the screen line containing IT's
@@ -9527,8 +9528,11 @@
        pos_limit = BEGV;
       else
        pos_limit = max (start_charpos + dvpos * nchars_per_row, BEGV);
+
       for (i = -dvpos; i > 0 && IT_CHARPOS (*it) > pos_limit; --i)
        back_to_previous_visible_line_start (it);
+      if (i > 0 && IT_CHARPOS (*it) <= pos_limit)
+       hit_pos_limit = true;
       reseat (it, it->current.pos, 1);
 
       /* Move further back if we end up in a string or an image.  */
@@ -9572,6 +9576,25 @@
          else
            bidi_unshelve_cache (it2data, 1);
        }
+      else if (hit_pos_limit && pos_limit > BEGV
+              && dvpos < 0 && it2.vpos < -dvpos)
+       {
+         /* If we hit the limit, but still didn't make it far enough
+            back, that means there's a display string with a newline
+            covering a large chunk of text, and that caused
+            back_to_previous_visible_line_start try to go too far.
+            Punish those who commit such atrocities by going back
+            until we've reached DVPOS, after lifting the limit, which
+            could make it slow for very long lines.  "If it hurts,
+            don't do that!"  */
+         dvpos += it2.vpos;
+         RESTORE_IT (it, it, it2data);
+         for (i = -dvpos; i > 0; --i)
+           {
+             back_to_previous_visible_line_start (it);
+             it->vpos--;
+           }
+       }
       else
        RESTORE_IT (it, it, it2data);
     }


reply via email to

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