From f3f948057ae78a551a2f83d89f7918623bed3e6e Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Mon, 20 Feb 2017 13:34:39 -0500 Subject: [PATCH v1] Fix scrolling with partial line corner case (Bug#25792) * src/xdisp.c (try_window): Take partial line height into account when comparing cursor position against scroll margin. --- src/xdisp.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/xdisp.c b/src/xdisp.c index e59934d2d5..6c94147844 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -17376,21 +17376,27 @@ try_window (Lisp_Object window, struct text_pos pos, int flags) return 0; } + /* Save the character position of 'it' before we call + 'start_display' again. */ + ptrdiff_t it_charpos = IT_CHARPOS (it); + /* Don't let the cursor end in the scroll margins. */ if ((flags & TRY_WINDOW_CHECK_MARGINS) && !MINI_WINDOW_P (w)) { int this_scroll_margin = window_scroll_margin (w, MARGIN_IN_PIXELS); + start_display (&it, w, pos); if ((w->cursor.y >= 0 /* not vscrolled */ && w->cursor.y < this_scroll_margin && CHARPOS (pos) > BEGV - && IT_CHARPOS (it) < ZV) + && it_charpos < ZV) /* rms: considering make_cursor_line_fully_visible_p here seems to give wrong results. We don't want to recenter when the last line is partly visible, we want to allow that case to be handled in the usual way. */ - || w->cursor.y > it.last_visible_y - this_scroll_margin - 1) + || w->cursor.y > (it.last_visible_y - partial_line_height (&it) + - this_scroll_margin - 1)) { w->cursor.vpos = -1; clear_glyph_matrix (w->desired_matrix); @@ -17399,7 +17405,7 @@ try_window (Lisp_Object window, struct text_pos pos, int flags) } /* If bottom moved off end of frame, change mode line percentage. */ - if (w->window_end_pos <= 0 && Z != IT_CHARPOS (it)) + if (w->window_end_pos <= 0 && Z != it_charpos) w->update_mode_line = true; /* Set window_end_pos to the offset of the last character displayed -- 2.11.1