]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix jumping cursor during interpolated scrolls
authorPo Lu <luangruo@yahoo.com>
Thu, 9 Dec 2021 03:40:39 +0000 (11:40 +0800)
committerPo Lu <luangruo@yahoo.com>
Thu, 9 Dec 2021 03:40:39 +0000 (11:40 +0800)
* lisp/pixel-scroll.el
(pixel-scroll-precision-scroll-down-page): Go to next position
before setting start or vscroll.

lisp/pixel-scroll.el

index 2bef8ca5b0ea26dd025d037b624a4030733f8b99..f21cdaed3d5843d552f16d7fa32b4b0d360d787d 100644 (file)
@@ -459,6 +459,14 @@ the height of the current window."
         (set-window-vscroll nil (+ (window-vscroll nil t)
                                    delta)
                             t)
+      (when (and (or (< (point) next-pos))
+                 (let ((pos-visibility (pos-visible-in-window-p next-pos nil t)))
+                   (and pos-visibility
+                        (or (eq (length pos-visibility) 2)
+                            (when-let* ((posn (posn-at-point next-pos)))
+                              (> (cdr (posn-object-width-height posn))
+                                 usable-height))))))
+        (goto-char next-pos))
       (set-window-start nil (if (zerop (window-hscroll))
                                 desired-start
                               (save-excursion
@@ -466,15 +474,7 @@ the height of the current window."
                                 (beginning-of-visual-line)
                                 (point)))
                         t)
-      (set-window-vscroll nil desired-vscroll t))
-    (if (and (or (< (point) next-pos))
-             (let ((pos-visibility (pos-visible-in-window-p next-pos nil t)))
-               (and pos-visibility
-                    (or (eq (length pos-visibility) 2)
-                        (when-let* ((posn (posn-at-point next-pos)))
-                          (> (cdr (posn-object-width-height posn))
-                             usable-height))))))
-        (goto-char next-pos))))
+      (set-window-vscroll nil desired-vscroll t))))
 
 (defun pixel-scroll-precision-scroll-down (delta)
   "Scroll the current window down by DELTA pixels."