Subject: Re: bug#19060: [FIX INCLUDED] Off-by-one-line scrolling bug in window_scroll_pixel_based

From: Eli Zaretskii <[email-masked]>
Date: Sat, 15 Nov 2014 13:17:47 +0200

> Date: Sat, 15 Nov 2014 12:13:17 +0100
> From: martin rudalics <[email-masked]>
> CC: [email-masked]
> 
>  > diff --git a/src/window.c b/src/window.c
>  > index b002423..7462fdc 100644
>  > --- a/src/window.c
>  > +++ b/src/window.c
>  > @@ -4956,8 +4956,8 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, int noerror)
>  >   	  int px;
>  >   	  int dy = frame_line_height;
>  >   	  if (whole)
>  > -	    dy = max ((window_box_height (w)
>  > -		       - next_screen_context_lines * dy),
>  > +	    dy = max ((window_box_height (w) / dy
>  > +		       - next_screen_context_lines) * dy,
>  >   		      dy);
>  >   	  dy *= n;
>  >
>  > @@ -5039,8 +5039,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, int noerror)
>  >       {
>  >         ptrdiff_t start_pos = IT_CHARPOS (it);
>  >         int dy = frame_line_height;
>  > -      dy = max ((window_box_height (w)
>  > -		 - next_screen_context_lines * dy),
>  > +      dy = max ((window_box_height (w) / dy - next_screen_context_lines) * dy,
>  >   		dy) * n;
>  >
>  >         /* Note that move_it_vertically always moves the iterator to the
> 
> If it works for you, please apply it.

It evidently works for Kelly.

> I'm too silly to understand it, though.  IIUC we have a rounding
> issue which makes us go by one line too far or too few when
> scrolling up and your patch compensates that rounding issue by
> putting it back into that window_box_height (w) / dy calculation.

Yes.  Why is it hard to understand?

> Could you add comments which tell more or less how you corrected the
> issue?

Will do, once we agree that this is the right fix.