Subject: Re: bug#5718: scroll-margin in buffer with small line count.

From: [email-masked]
Date: Sun, 15 Jan 2017 16:43:34 -0500

Eli Zaretskii <[email-masked]> writes:

>> From: [email-masked]
>> Cc: [email-masked],  [email-masked],  [email-masked]
>> Date: Fri, 13 Jan 2017 23:18:56 -0500
>> 
>> Looks like the same kind of problem as the other case, I can fix it
>> again by subtracting frame_line_height, though again, subtracting the
>> partial height is probably more correct.
>
> I think you are right on both counts.  Computing the partial height of
> the last visible line shouldn't be hard, I think.  Let me know if you
> need help with that.

Yeah, I'm still a bit lost in all the different structures.  It seems
(it.last_visible_y % frame_line_height) might work.  The matrix row
stuff in xdisp seems a more direct way of getting it, though I guess
that's not really usable from window.c?  What would be the idiomatic way
of doing this?

#define MR_PARTIALLY_VISIBLE(ROW)	\
  ((ROW)->height != (ROW)->visible_height)

By the way, in window_scroll_pixel_based (lines 5139 to 5158) the
position of "it" is saved twice, and it looks like the first one of
these can never be used (because the second overwrites it), correct?

      ptrdiff_t charpos, bytepos;
      bool partial_p;

      /* Save our position, for the   <---------------- Useless?
	 window_scroll_pixel_based_preserve_y case.  */
      charpos = IT_CHARPOS (it);
      bytepos = IT_BYTEPOS (it);

      /* We moved the window start towards BEGV, so PT may be now
	 in the scroll margin at the bottom.  */
      move_it_to (&it, PT, -1,
		  (it.last_visible_y - WINDOW_HEADER_LINE_HEIGHT (w)
		   - this_scroll_margin - 1 - frame_line_height),
		  -1,
		  MOVE_TO_POS | MOVE_TO_Y);

      /* Save our position, in case it's correct.  */
      charpos = IT_CHARPOS (it);
      bytepos = IT_BYTEPOS (it);