diff options
author | Gerd Möllmann <gerd@gnu.org> | 2022-08-23 15:50:25 +0200 |
---|---|---|
committer | Gerd Möllmann <gerd@gnu.org> | 2022-08-23 15:53:10 +0200 |
commit | 1f990d1cf95930a584a7f70f002f284e273b6fd6 (patch) | |
tree | 26b210c75dcac0fa351d71d8410b75ce69060881 | |
parent | 76982f08683643a0e087a69c5d8c3eea1d36715e (diff) | |
download | emacs-1f990d1cf95930a584a7f70f002f284e273b6fd6.tar.gz |
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)
-rw-r--r-- | lisp/pixel-scroll.el | 20 |
1 files 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 |