From 1f990d1cf95930a584a7f70f002f284e273b6fd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerd=20M=C3=B6llmann?= Date: Tue, 23 Aug 2022 15:50:25 +0200 Subject: Fix pixel-scroll-precision in a corner case * lisp/pixel-scroll.el (pixel-scroll-precision-scroll-up-page): Handle case that point cannot be found. (pixel-scroll-precision-scroll-up): Handle case that window is one line high (bug#57349) --- lisp/pixel-scroll.el | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lisp/pixel-scroll.el b/lisp/pixel-scroll.el index 6dba733b9c4..167cb4fabe8 100644 --- a/lisp/pixel-scroll.el +++ b/lisp/pixel-scroll.el @@ -570,11 +570,12 @@ the height of the current window." (window-header-line-height) (- max-y delta)))) (point (posn-point posn)) - (up-point (save-excursion - (goto-char point) - (vertical-motion (- (1+ scroll-margin))) - (point)))) - (when (> (point) up-point) + (up-point (and point + (save-excursion + (goto-char point) + (vertical-motion (- (1+ scroll-margin))) + (point))))) + (when (and point (> (point) up-point)) (when (let ((pos-visible (pos-visible-in-window-p up-point nil t))) (or (eq (length pos-visible) 2) (when-let* ((posn (posn-at-point up-point)) @@ -665,10 +666,11 @@ window being scrolled by DELTA pixels with an animation." "Scroll the current window up by DELTA pixels." (let ((max-height (- (window-text-height nil t) (frame-char-height)))) - (while (> delta max-height) - (pixel-scroll-precision-scroll-up-page max-height) - (setq delta (- delta max-height))) - (pixel-scroll-precision-scroll-up-page delta))) + (when (> max-height 0) + (while (> delta max-height) + (pixel-scroll-precision-scroll-up-page max-height) + (setq delta (- delta max-height))) + (pixel-scroll-precision-scroll-up-page delta)))) ;; FIXME: This doesn't _always_ work when there's an image above the ;; current line that is taller than the window, and scrolling can -- cgit v1.2.1