diff options
| author | Eli Zaretskii | 2012-11-06 18:36:02 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2012-11-06 18:36:02 +0200 |
| commit | acf93bcf1922b4d157c217a7a76b30d028d1043d (patch) | |
| tree | 1842ec8cc533e92ac09ff591cbc60698dd10502d /src | |
| parent | 072c7b659c4b80e453666ba6c6724c3a547ffdb7 (diff) | |
| download | emacs-acf93bcf1922b4d157c217a7a76b30d028d1043d.tar.gz emacs-acf93bcf1922b4d157c217a7a76b30d028d1043d.zip | |
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 @@ | |||
| 1 | 2012-11-06 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * xdisp.c (try_scrolling): Fix correction of aggressive-scroll | ||
| 4 | amount when the scroll margins are too large. When scrolling | ||
| 5 | backwards in the buffer, give up if cannot reach point or the | ||
| 6 | scroll margin within a reasonable number of screen lines. Fixes | ||
| 7 | point position in window under scroll-up/down-aggressively when | ||
| 8 | point is positioned many lines beyond the window top/bottom. | ||
| 9 | (Bug#12811) | ||
| 10 | |||
| 1 | 2012-11-05 Eli Zaretskii <eliz@gnu.org> | 11 | 2012-11-05 Eli Zaretskii <eliz@gnu.org> |
| 2 | 12 | ||
| 3 | * ralloc.c (relinquish): If real_morecore fails to return memory | 13 | * 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, | |||
| 14791 | if (NUMBERP (aggressive)) | 14791 | if (NUMBERP (aggressive)) |
| 14792 | { | 14792 | { |
| 14793 | double float_amount = XFLOATINT (aggressive) * height; | 14793 | double float_amount = XFLOATINT (aggressive) * height; |
| 14794 | amount_to_scroll = float_amount; | 14794 | int aggressive_scroll = float_amount; |
| 14795 | if (amount_to_scroll == 0 && float_amount > 0) | 14795 | if (aggressive_scroll == 0 && float_amount > 0) |
| 14796 | amount_to_scroll = 1; | 14796 | aggressive_scroll = 1; |
| 14797 | /* Don't let point enter the scroll margin near top of | 14797 | /* Don't let point enter the scroll margin near top of |
| 14798 | the window. */ | 14798 | the window. This could happen if the value of |
| 14799 | if (amount_to_scroll > height - 2*this_scroll_margin + dy) | 14799 | scroll_up_aggressively is too large and there are |
| 14800 | amount_to_scroll = height - 2*this_scroll_margin + dy; | 14800 | non-zero margins, because scroll_up_aggressively |
| 14801 | means put point that fraction of window height | ||
| 14802 | _from_the_bottom_margin_. */ | ||
| 14803 | if (aggressive_scroll + 2*this_scroll_margin > height) | ||
| 14804 | aggressive_scroll = height - 2*this_scroll_margin; | ||
| 14805 | amount_to_scroll = dy + aggressive_scroll; | ||
| 14801 | } | 14806 | } |
| 14802 | } | 14807 | } |
| 14803 | 14808 | ||
| @@ -14857,7 +14862,8 @@ try_scrolling (Lisp_Object window, int just_this_one_p, | |||
| 14857 | /* Compute the vertical distance from PT to the scroll | 14862 | /* Compute the vertical distance from PT to the scroll |
| 14858 | margin position. Move as far as scroll_max allows, or | 14863 | margin position. Move as far as scroll_max allows, or |
| 14859 | one screenful, or 10 screen lines, whichever is largest. | 14864 | one screenful, or 10 screen lines, whichever is largest. |
| 14860 | Give up if distance is greater than scroll_max. */ | 14865 | Give up if distance is greater than scroll_max or if we |
| 14866 | didn't reach the scroll margin position. */ | ||
| 14861 | SET_TEXT_POS (pos, PT, PT_BYTE); | 14867 | SET_TEXT_POS (pos, PT, PT_BYTE); |
| 14862 | start_display (&it, w, pos); | 14868 | start_display (&it, w, pos); |
| 14863 | y0 = it.current_y; | 14869 | y0 = it.current_y; |
| @@ -14867,7 +14873,8 @@ try_scrolling (Lisp_Object window, int just_this_one_p, | |||
| 14867 | y_to_move, -1, | 14873 | y_to_move, -1, |
| 14868 | MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y); | 14874 | MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y); |
| 14869 | dy = it.current_y - y0; | 14875 | dy = it.current_y - y0; |
| 14870 | if (dy > scroll_max) | 14876 | if (dy > scroll_max |
| 14877 | || IT_CHARPOS (it) < CHARPOS (scroll_margin_pos)) | ||
| 14871 | return SCROLLING_FAILED; | 14878 | return SCROLLING_FAILED; |
| 14872 | 14879 | ||
| 14873 | /* Compute new window start. */ | 14880 | /* Compute new window start. */ |
| @@ -14885,15 +14892,16 @@ try_scrolling (Lisp_Object window, int just_this_one_p, | |||
| 14885 | if (NUMBERP (aggressive)) | 14892 | if (NUMBERP (aggressive)) |
| 14886 | { | 14893 | { |
| 14887 | double float_amount = XFLOATINT (aggressive) * height; | 14894 | double float_amount = XFLOATINT (aggressive) * height; |
| 14888 | amount_to_scroll = float_amount; | 14895 | int aggressive_scroll = float_amount; |
| 14889 | if (amount_to_scroll == 0 && float_amount > 0) | 14896 | if (aggressive_scroll == 0 && float_amount > 0) |
| 14890 | amount_to_scroll = 1; | 14897 | aggressive_scroll = 1; |
| 14891 | amount_to_scroll -= | ||
| 14892 | this_scroll_margin - dy - FRAME_LINE_HEIGHT (f); | ||
| 14893 | /* Don't let point enter the scroll margin near | 14898 | /* Don't let point enter the scroll margin near |
| 14894 | bottom of the window. */ | 14899 | bottom of the window, if the value of |
| 14895 | if (amount_to_scroll > height - 2*this_scroll_margin + dy) | 14900 | scroll_down_aggressively happens to be too |
| 14896 | amount_to_scroll = height - 2*this_scroll_margin + dy; | 14901 | large. */ |
| 14902 | if (aggressive_scroll + 2*this_scroll_margin > height) | ||
| 14903 | aggressive_scroll = height - 2*this_scroll_margin; | ||
| 14904 | amount_to_scroll = dy + aggressive_scroll; | ||
| 14897 | } | 14905 | } |
| 14898 | } | 14906 | } |
| 14899 | 14907 | ||