]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix pixel-scroll-precision in a corner case
authorGerd Möllmann <gerd@gnu.org>
Tue, 23 Aug 2022 13:50:25 +0000 (15:50 +0200)
committerGerd Möllmann <gerd@gnu.org>
Tue, 23 Aug 2022 13:53:10 +0000 (15:53 +0200)
* 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

index 6dba733b9c4dce8a33f5d49bea86eedf73396989..167cb4fabe880a1e26e79ebeb4317e7ecba656a0 100644 (file)
@@ -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