Commit c4131562 authored by Eli Zaretskii's avatar Eli Zaretskii
Browse files

Fix cursor positioning near scroll margin at top of window.

 src/xdisp.c (try_scrolling): Scroll text up more if point is too close
 to ZV and inside the scroll margin.  This makes sure point is moved
 outside the scroll margin in these cases.
parent 33b49d71
......@@ -6,6 +6,9 @@
it->region_beg_charpos, not to -1. This fixes redisplay
optimization when cursor is moved up after M->. (Bug#13623)
(Bug#13626)
(try_scrolling): Scroll text up more if point is too close to ZV
and inside the scroll margin. This makes sure point is moved
outside the scroll margin in these cases.
 
* window.h (struct window): region_showing can no longer be
negative.
......
......@@ -14604,14 +14604,24 @@ try_scrolling (Lisp_Object window, int just_this_one_p,
else
{
struct text_pos scroll_margin_pos = startp;
int y_offset = 0;
 
/* See if point is inside the scroll margin at the top of the
window. */
if (this_scroll_margin)
{
int y_start;
start_display (&it, w, startp);
y_start = it.current_y;
move_it_vertically (&it, this_scroll_margin);
scroll_margin_pos = it.current.pos;
/* If we didn't move enough before hitting ZV, request
additional amount of scroll, to move point out of the
scroll margin. */
if (IT_CHARPOS (it) == ZV
&& it.current_y - y_start < this_scroll_margin)
y_offset = this_scroll_margin - (it.current_y - y_start);
}
 
if (PT < CHARPOS (scroll_margin_pos))
......@@ -14638,6 +14648,9 @@ try_scrolling (Lisp_Object window, int just_this_one_p,
|| IT_CHARPOS (it) < CHARPOS (scroll_margin_pos))
return SCROLLING_FAILED;
 
/* Additional scroll for when ZV was too close to point. */
dy += y_offset;
/* Compute new window start. */
start_display (&it, w, startp);
 
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment