diff options
Diffstat (limited to 'src/window.c')
| -rw-r--r-- | src/window.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/window.c b/src/window.c index 49d7fc2426b..fe685d5ab09 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -5445,6 +5445,11 @@ window_scroll_margin (struct window *window, enum margin_unit unit) | |||
| 5445 | return 0; | 5445 | return 0; |
| 5446 | } | 5446 | } |
| 5447 | 5447 | ||
| 5448 | static int | ||
| 5449 | sanitize_next_screen_context_lines (void) | ||
| 5450 | { | ||
| 5451 | return clip_to_bounds (0, next_screen_context_lines, 1000000); | ||
| 5452 | } | ||
| 5448 | 5453 | ||
| 5449 | /* Implementation of window_scroll that works based on pixel line | 5454 | /* Implementation of window_scroll that works based on pixel line |
| 5450 | heights. See the comment of window_scroll for parameter | 5455 | heights. See the comment of window_scroll for parameter |
| @@ -5515,9 +5520,11 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, bool noerror) | |||
| 5515 | height. This is important to ensure we get back to the | 5520 | height. This is important to ensure we get back to the |
| 5516 | same position when scrolling up, then down. */ | 5521 | same position when scrolling up, then down. */ |
| 5517 | if (whole) | 5522 | if (whole) |
| 5518 | dy = max ((window_box_height (w) / dy | 5523 | { |
| 5519 | - next_screen_context_lines) * dy, | 5524 | int ht = window_box_height (w); |
| 5520 | dy); | 5525 | int nscls = sanitize_next_screen_context_lines (); |
| 5526 | dy = max (dy, (ht / dy - nscls) * dy); | ||
| 5527 | } | ||
| 5521 | dy *= n; | 5528 | dy *= n; |
| 5522 | 5529 | ||
| 5523 | if (n < 0) | 5530 | if (n < 0) |
| @@ -5598,13 +5605,14 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, bool noerror) | |||
| 5598 | { | 5605 | { |
| 5599 | ptrdiff_t start_pos = IT_CHARPOS (it); | 5606 | ptrdiff_t start_pos = IT_CHARPOS (it); |
| 5600 | int dy = frame_line_height; | 5607 | int dy = frame_line_height; |
| 5608 | int ht = window_box_height (w); | ||
| 5609 | int nscls = sanitize_next_screen_context_lines (); | ||
| 5601 | /* In the below we divide the window box height by the frame's | 5610 | /* In the below we divide the window box height by the frame's |
| 5602 | line height to make the result predictable when the window | 5611 | line height to make the result predictable when the window |
| 5603 | box is not an integral multiple of the line height. This is | 5612 | box is not an integral multiple of the line height. This is |
| 5604 | important to ensure we get back to the same position when | 5613 | important to ensure we get back to the same position when |
| 5605 | scrolling up, then down. */ | 5614 | scrolling up, then down. */ |
| 5606 | dy = max ((window_box_height (w) / dy - next_screen_context_lines) * dy, | 5615 | dy = n * max (dy, (ht / dy - nscls) * dy); |
| 5607 | dy) * n; | ||
| 5608 | 5616 | ||
| 5609 | /* Note that move_it_vertically always moves the iterator to the | 5617 | /* Note that move_it_vertically always moves the iterator to the |
| 5610 | start of a line. So, if the last line doesn't have a newline, | 5618 | start of a line. So, if the last line doesn't have a newline, |
| @@ -5902,7 +5910,10 @@ window_scroll_line_based (Lisp_Object window, int n, bool whole, bool noerror) | |||
| 5902 | /* If scrolling screen-fulls, compute the number of lines to | 5910 | /* If scrolling screen-fulls, compute the number of lines to |
| 5903 | scroll from the window's height. */ | 5911 | scroll from the window's height. */ |
| 5904 | if (whole) | 5912 | if (whole) |
| 5905 | n *= max (1, ht - next_screen_context_lines); | 5913 | { |
| 5914 | int nscls = sanitize_next_screen_context_lines (); | ||
| 5915 | n *= max (1, ht - nscls); | ||
| 5916 | } | ||
| 5906 | 5917 | ||
| 5907 | if (!NILP (Vscroll_preserve_screen_position)) | 5918 | if (!NILP (Vscroll_preserve_screen_position)) |
| 5908 | { | 5919 | { |