emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-27 32a3758: Fix infloop in 'pixel-scroll-mode'


From: Eli Zaretskii
Subject: emacs-27 32a3758: Fix infloop in 'pixel-scroll-mode'
Date: Sat, 9 Jan 2021 04:21:31 -0500 (EST)

branch: emacs-27
commit 32a3758c84a6031b118fbcce91606d307a93cc14
Author: Tak Kunihiro <tkk@misasa.okayama-u.ac.jp>
Commit: Eli Zaretskii <eliz@gnu.org>

    Fix infloop in 'pixel-scroll-mode'
    
    * lisp/pixel-scroll.el (pixel-scroll-up, pixel-scroll-down): Avoid
    inflooping when 'vertical-motion' doesn't move.  (Bug#45628)
---
 lisp/pixel-scroll.el | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lisp/pixel-scroll.el b/lisp/pixel-scroll.el
index 8e6e049..f722c25 100644
--- a/lisp/pixel-scroll.el
+++ b/lisp/pixel-scroll.el
@@ -133,8 +133,10 @@ This is an alternative of `scroll-up'.  Scope moves 
downward."
                    (pixel-line-height))))
         (if (pixel-eob-at-top-p)      ; when end-of-the-buffer is close
             (scroll-up 1)             ; relay on robust method
-          (while (pixel-point-at-top-p amt) ; prevent too late (multi tries)
-            (vertical-motion 1))            ; move point downward
+          (catch 'no-movement
+            (while (pixel-point-at-top-p amt) ; prevent too late (multi tries)
+              (unless (>= (vertical-motion 1) 1) ; move point downward
+                (throw 'no-movement nil)))) ; exit loop when point did not move
           (pixel-scroll-pixel-up amt))))))  ; move scope downward
 
 (defun pixel-scroll-down (&optional arg)
@@ -150,8 +152,10 @@ This is and alternative of `scroll-down'.  Scope moves 
upward."
                          pixel-resolution-fine-flag
                        (frame-char-height))
                    (pixel-line-height -1))))
-        (while (pixel-point-at-bottom-p amt) ; prevent too late (multi tries)
-          (vertical-motion -1))              ; move point upward
+        (catch 'no-movement
+          (while (pixel-point-at-bottom-p amt) ; prevent too late (multi tries)
+            (unless (<= (vertical-motion -1) -1) ; move point upward
+              (throw 'no-movement nil)))) ; exit loop when point did not move
         (if (or (pixel-bob-at-top-p amt) ; when beginning-of-the-buffer is seen
                 (pixel-eob-at-top-p))    ; for file with a long line
             (scroll-down 1)              ; relay on robust method



reply via email to

[Prev in Thread] Current Thread [Next in Thread]