Fix failures in try_scrolling when scrolling back.
authorEli Zaretskii <eliz@gnu.org>
Mon, 28 Mar 2011 19:30:35 +0000 (21:30 +0200)
committerEli Zaretskii <eliz@gnu.org>
Mon, 28 Mar 2011 19:30:35 +0000 (21:30 +0200)
 src/xdisp.c (try_scrolling): When point is above the window, allow
 searching as far as scroll_max, or one screenful, to compute
 vertical distance from PT to the scroll margin position.  This
 prevents try_scrolling from unnecessarily failing when
 scroll-conservatively is set to a value slightly larger than the
 window height.

src/ChangeLog
src/xdisp.c

index e7a93ab..cb9096a 100644 (file)
@@ -1,3 +1,12 @@
+2011-03-28  Eli Zaretskii  <eliz@gnu.org>
+
+       * xdisp.c (try_scrolling): When point is above the window, allow
+       searching as far as scroll_max, or one screenful, to compute
+       vertical distance from PT to the scroll margin position.  This
+       prevents try_scrolling from unnecessarily failing when
+       scroll-conservatively is set to a value slightly larger than the
+       window height.
+
 2011-03-27  Eli Zaretskii  <eliz@gnu.org>
 
        * xdisp.c (try_scrolling): Clean up the case of PT below the
index 1b72f2e..871d070 100644 (file)
@@ -13176,16 +13176,19 @@ try_scrolling (Lisp_Object window, int just_this_one_p,
        {
          /* Point is in the scroll margin at the top of the window or
             above what is displayed in the window.  */
-         int y0;
+         int y0, y_to_move;
 
          /* Compute the vertical distance from PT to the scroll
-            margin position.  Give up if distance is greater than
-            scroll_max.  */
+            margin position.  Move as far as scroll_max allows, or
+            one screenful, or 10 screen lines, whichever is largest.
+            Give up if distance is greater than scroll_max.  */
          SET_TEXT_POS (pos, PT, PT_BYTE);
          start_display (&it, w, pos);
          y0 = it.current_y;
+         y_to_move = max (it.last_visible_y,
+                          max (scroll_max, 10 * FRAME_LINE_HEIGHT (f)));
          move_it_to (&it, CHARPOS (scroll_margin_pos), 0,
-                     it.last_visible_y, -1,
+                     y_to_move, -1,
                      MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y);
          dy = it.current_y - y0;
          if (dy > scroll_max)