From 9f3842cef7423e3ce6f75721284e6351f3a200e5 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 28 Mar 2011 21:30:35 +0200 Subject: [PATCH] Fix failures in try_scrolling when scrolling back. 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 | 9 +++++++++ src/xdisp.c | 11 +++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index e7a93ab7819..cb9096a5a5c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2011-03-28 Eli Zaretskii + + * 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 * xdisp.c (try_scrolling): Clean up the case of PT below the diff --git a/src/xdisp.c b/src/xdisp.c index 1b72f2e3081..871d070ed31 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -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) -- 2.39.2