From 6b351b2d7608def23cc4bbd76ba8dc300708e953 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 8 Feb 2021 18:04:00 +0200 Subject: [PATCH] Fix scrolling past tall images * src/xdisp.c (try_window): Don't try checking the margins if the window is vscrolled, as that could cause unnecessary recentering when tall images are displayed. (Bug#46320) --- src/xdisp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/xdisp.c b/src/xdisp.c index 1815f986781..fb8eaf4b967 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -19452,8 +19452,11 @@ try_window (Lisp_Object window, struct text_pos pos, int flags) 'start_display' again. */ ptrdiff_t it_charpos = IT_CHARPOS (it); - /* Don't let the cursor end in the scroll margins. */ + /* Don't let the cursor end in the scroll margins. However, when + the window is vscrolled, we leave it to vscroll to handle the + margins, see window_scroll_pixel_based. */ if ((flags & TRY_WINDOW_CHECK_MARGINS) + && w->vscroll == 0 && !MINI_WINDOW_P (w)) { int top_scroll_margin = window_scroll_margin (w, MARGIN_IN_PIXELS); @@ -19462,7 +19465,7 @@ try_window (Lisp_Object window, struct text_pos pos, int flags) top_scroll_margin += CURRENT_HEADER_LINE_HEIGHT (w); start_display (&it, w, pos); - if ((w->cursor.y >= 0 /* not vscrolled */ + if ((w->cursor.y >= 0 && w->cursor.y < top_scroll_margin && CHARPOS (pos) > BEGV) /* rms: considering make_cursor_line_fully_visible_p here -- 2.39.5