From 52f3fe46a35df28cc7a07c0a3f551e67760455b2 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Thu, 9 Dec 2021 11:40:39 +0800 Subject: [PATCH] Fix jumping cursor during interpolated scrolls * lisp/pixel-scroll.el (pixel-scroll-precision-scroll-down-page): Go to next position before setting start or vscroll. --- lisp/pixel-scroll.el | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lisp/pixel-scroll.el b/lisp/pixel-scroll.el index 2bef8ca5b0e..f21cdaed3d5 100644 --- a/lisp/pixel-scroll.el +++ b/lisp/pixel-scroll.el @@ -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." -- 2.39.2