[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/scroll-on-jump fddbdfdfe0 11/31: Fix error where the pixel
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/scroll-on-jump fddbdfdfe0 11/31: Fix error where the pixel scroll was left a non-zero value |
Date: |
Thu, 7 Jul 2022 12:03:12 -0400 (EDT) |
branch: elpa/scroll-on-jump
commit fddbdfdfe05c08f846c8b990c521bfe95efbc577
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>
Fix error where the pixel scroll was left a non-zero value
---
scroll-on-jump.el | 57 +++++++++++++++++++++++++++++++++++--------------------
1 file changed, 36 insertions(+), 21 deletions(-)
diff --git a/scroll-on-jump.el b/scroll-on-jump.el
index 5bf22eb27f..6d57efd3a3 100644
--- a/scroll-on-jump.el
+++ b/scroll-on-jump.el
@@ -111,20 +111,23 @@ Argument ALSO-MOVE-POINT When non-nil, move the POINT as
well."
((< delta-px 0)
(let*
(
- (scroll-px-prev (- char-height (window-vscroll nil t))) ;; flip.
- (scroll-px-next (+ scroll-px-prev (- delta-px))) ;; flip.
+ (scroll-px-prev (window-vscroll nil t))
+ (scroll-px-next (+ scroll-px-prev delta-px))
(lines (/ scroll-px-next char-height))
(scroll-px (- scroll-px-next (* lines char-height)))
(lines-remainder 0))
+
+ (when (< scroll-px 0)
+ (setq lines (1- lines))
+ (setq scroll-px (+ char-height scroll-px)))
+
(unless (zerop lines)
- ;; flip
- (setq lines-remainder
- (- (scroll-on-jump--scroll-by-lines window (- lines)
also-move-point)))
+ (setq lines-remainder (- (scroll-on-jump--scroll-by-lines window
lines also-move-point)))
(unless (zerop lines-remainder)
- (setq scroll-px char-height)))
- (set-window-vscroll window (- char-height scroll-px) t)
+ (setq scroll-px 0)))
+ (set-window-vscroll window scroll-px t)
- (cons (- lines-remainder) (- lines))))
+ (cons lines-remainder lines)))
((> delta-px 0)
(let*
(
@@ -206,7 +209,8 @@ Argument ALSO-MOVE-POINT When non-nil, move the POINT as
well."
(setq step (- step (* dir (- lines-done-abs
lines-scroll-abs)))))
;; Faster alternative to scroll.
- (scroll-on-jump--scroll-by-lines-simple window step t)
+ (scroll-on-jump--scroll-by-lines-simple window step nil)
+ (forward-line step)
(setq lines-scroll (- lines-scroll step)))
@@ -278,8 +282,7 @@ Argument ALSO-MOVE-POINT When non-nil, move the POINT as
well."
(t
(* px-scroll-abs factor)))))
(px-remainder (- px-target px-done-abs)))
- ;; Step result, we must move at least one pixel.
- (* dir (max 1 (floor px-remainder))))))
+ (* dir px-remainder))))
;; Check if this is the last step.
(setq px-done-abs (+ px-done-abs (abs step)))
@@ -289,7 +292,12 @@ Argument ALSO-MOVE-POINT When non-nil, move the POINT as
well."
(pcase-let
(
(`(,_lines-remainder . ,lines-handled)
- (scroll-on-jump--scroll-by-pixels window char-height step
t)))
+ (scroll-on-jump--scroll-by-pixels window char-height step
nil)))
+
+ ;; Forward lines separately since we might be at end of the
buffer
+ ;; and we want to be able to scroll - even if the point has
reached it's limit.
+ (forward-line lines-handled)
+
(setq lines-scroll (- lines-scroll lines-handled)))
(setq px-scroll (- px-scroll step)))
@@ -298,15 +306,22 @@ Argument ALSO-MOVE-POINT When non-nil, move the POINT as
well."
(redisplay t))
(setq is-early-exit nil))
- ;; ;; Re-enable when editing logic.
- (when (and (null is-early-exit) (not (zerop px-scroll)))
- (set-window-vscroll window 0 t)
- (error "Internal error, 'px-scroll' should be zero"))
-
- ;; If we exit early because of input.
- (when is-early-exit
- (set-window-vscroll window 0 t)
- (scroll-on-jump--scroll-by-lines-simple window lines-scroll nil)))
+ (cond
+ ;; If we exit early because of input.
+ (is-early-exit
+ ;; Early exit, reset pixel scroll and scroll lines.
+ (set-window-vscroll window 0 t)
+ (scroll-on-jump--scroll-by-lines-simple window lines-scroll nil))
+
+ ;; Sanity check, if this fails there is an issue with internal logic.
+ ((not (zerop px-scroll))
+ (set-window-vscroll window 0 t)
+ (error "Internal error, 'px-scroll' should be zero"))
+
+ ;; Also should never happen.
+ ((not (zerop (window-vscroll window t)))
+ (set-window-vscroll window 0 t)
+ (message "Warning, sub-pixel scroll left set!"))))
;; Non-animated scrolling (immediate).
(scroll-on-jump--scroll-by-lines-simple window lines-scroll nil)))
- [nongnu] branch elpa/scroll-on-jump created (now 8fde237ae6), ELPA Syncer, 2022/07/07
- [nongnu] elpa/scroll-on-jump 4b11cda039 07/31: Cleanup: pass the window to count-screen-lines, ELPA Syncer, 2022/07/07
- [nongnu] elpa/scroll-on-jump 94986120c4 08/31: readme: add link to demo video, ELPA Syncer, 2022/07/07
- [nongnu] elpa/scroll-on-jump fddbdfdfe0 11/31: Fix error where the pixel scroll was left a non-zero value,
ELPA Syncer <=
- [nongnu] elpa/scroll-on-jump 42329b5707 20/31: Fix visual glitch when used with next/previous line, ELPA Syncer, 2022/07/07
- [nongnu] elpa/scroll-on-jump 5007e9ea8a 18/31: readme: add examples suggested in #2, ELPA Syncer, 2022/07/07
- [nongnu] elpa/scroll-on-jump 69c86542a1 15/31: Docs: add docstrings, ELPA Syncer, 2022/07/07
- [nongnu] elpa/scroll-on-jump dd2818d906 17/31: Cleanup: make docstring under 80 chars, ELPA Syncer, 2022/07/07
- [nongnu] elpa/scroll-on-jump 30dc5f5e50 21/31: Cleanup: remove recursion check, ELPA Syncer, 2022/07/07
- [nongnu] elpa/scroll-on-jump 28bac2cdc3 22/31: Cleanup: quiet checkdoc warnings for wide docstrings, ELPA Syncer, 2022/07/07
- [nongnu] elpa/scroll-on-jump 0ce93b3ea6 19/31: readme: remove 'evil-goto-first-line' as 'evil-goto-line' already scrolls, ELPA Syncer, 2022/07/07
- [nongnu] elpa/scroll-on-jump 000dc41039 25/31: Fix error passing out-of-range point to count-screen-lines, ELPA Syncer, 2022/07/07
- [nongnu] elpa/scroll-on-jump 99386fc01b 30/31: Cleanup: use brief SPDX license, ELPA Syncer, 2022/07/07
- [nongnu] elpa/scroll-on-jump 556e9a7a81 28/31: Fix error detecting scroll changes, ELPA Syncer, 2022/07/07