diff options
author | Eli Zaretskii <[email protected]> | 2013-02-12 18:43:09 +0200 |
---|---|---|
committer | Eli Zaretskii <[email protected]> | 2013-02-12 18:43:09 +0200 |
commit | c4131562319d3529841136d236ac39fb1e3d2b7c (patch) | |
tree | 5ad493efa9ff4e2c5d53dc39632c759f710717c3 | |
parent | 33b49d71e45e3be1db4577277763f1cb3138d225 (diff) |
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.
-rw-r--r-- | src/ChangeLog | 3 | ||||
-rw-r--r-- | src/xdisp.c | 13 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index fb4cc72364..05737bb119 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -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. diff --git a/src/xdisp.c b/src/xdisp.c index ca3f968afa..d2d4b3bbb7 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -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); |