diff options
author | Eli Zaretskii <eliz@gnu.org> | 2012-11-06 18:36:02 +0200 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2012-11-06 18:36:02 +0200 |
commit | acf93bcf1922b4d157c217a7a76b30d028d1043d (patch) | |
tree | 1842ec8cc533e92ac09ff591cbc60698dd10502d /src | |
parent | 072c7b659c4b80e453666ba6c6724c3a547ffdb7 (diff) | |
download | emacs-acf93bcf1922b4d157c217a7a76b30d028d1043d.tar.gz |
Fix bug #12811 with scrolling under scroll-up/down-aggressively.
src/xdisp.c (try_scrolling): Fix correction of aggressive-scroll
amount when the scroll margins are too large. When scrolling
backwards in the buffer, give up if cannot reach point or the
scroll margin within a reasonable number of screen lines. Fixes
point position in window under scroll-up/down-aggressively when
point is positioned many lines beyond the window top/bottom.
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 10 | ||||
-rw-r--r-- | src/xdisp.c | 40 |
2 files changed, 34 insertions, 16 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index c49039a3cf9..11e657cffa9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2012-11-06 Eli Zaretskii <eliz@gnu.org> + + * xdisp.c (try_scrolling): Fix correction of aggressive-scroll + amount when the scroll margins are too large. When scrolling + backwards in the buffer, give up if cannot reach point or the + scroll margin within a reasonable number of screen lines. Fixes + point position in window under scroll-up/down-aggressively when + point is positioned many lines beyond the window top/bottom. + (Bug#12811) + 2012-11-05 Eli Zaretskii <eliz@gnu.org> * ralloc.c (relinquish): If real_morecore fails to return memory diff --git a/src/xdisp.c b/src/xdisp.c index bc1cbd94bd5..c7195504c4c 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -14791,13 +14791,18 @@ try_scrolling (Lisp_Object window, int just_this_one_p, if (NUMBERP (aggressive)) { double float_amount = XFLOATINT (aggressive) * height; - amount_to_scroll = float_amount; - if (amount_to_scroll == 0 && float_amount > 0) - amount_to_scroll = 1; + int aggressive_scroll = float_amount; + if (aggressive_scroll == 0 && float_amount > 0) + aggressive_scroll = 1; /* Don't let point enter the scroll margin near top of - the window. */ - if (amount_to_scroll > height - 2*this_scroll_margin + dy) - amount_to_scroll = height - 2*this_scroll_margin + dy; + the window. This could happen if the value of + scroll_up_aggressively is too large and there are + non-zero margins, because scroll_up_aggressively + means put point that fraction of window height + _from_the_bottom_margin_. */ + if (aggressive_scroll + 2*this_scroll_margin > height) + aggressive_scroll = height - 2*this_scroll_margin; + amount_to_scroll = dy + aggressive_scroll; } } @@ -14857,7 +14862,8 @@ try_scrolling (Lisp_Object window, int just_this_one_p, /* Compute the vertical distance from PT to the scroll 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. */ + Give up if distance is greater than scroll_max or if we + didn't reach the scroll margin position. */ SET_TEXT_POS (pos, PT, PT_BYTE); start_display (&it, w, pos); y0 = it.current_y; @@ -14867,7 +14873,8 @@ try_scrolling (Lisp_Object window, int just_this_one_p, y_to_move, -1, MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y); dy = it.current_y - y0; - if (dy > scroll_max) + if (dy > scroll_max + || IT_CHARPOS (it) < CHARPOS (scroll_margin_pos)) return SCROLLING_FAILED; /* Compute new window start. */ @@ -14885,15 +14892,16 @@ try_scrolling (Lisp_Object window, int just_this_one_p, if (NUMBERP (aggressive)) { double float_amount = XFLOATINT (aggressive) * height; - amount_to_scroll = float_amount; - if (amount_to_scroll == 0 && float_amount > 0) - amount_to_scroll = 1; - amount_to_scroll -= - this_scroll_margin - dy - FRAME_LINE_HEIGHT (f); + int aggressive_scroll = float_amount; + if (aggressive_scroll == 0 && float_amount > 0) + aggressive_scroll = 1; /* Don't let point enter the scroll margin near - bottom of the window. */ - if (amount_to_scroll > height - 2*this_scroll_margin + dy) - amount_to_scroll = height - 2*this_scroll_margin + dy; + bottom of the window, if the value of + scroll_down_aggressively happens to be too + large. */ + if (aggressive_scroll + 2*this_scroll_margin > height) + aggressive_scroll = height - 2*this_scroll_margin; + amount_to_scroll = dy + aggressive_scroll; } } |