fix(smooth-scroll): potential out-of-bounds error

Wherever an interactive motion command (that good-scroll has advised) is
used programmatically.

This should be addressed upstream. Either by adding
boundary/called-interactively guards to
`good-scroll--point-at-top-fix-a`, or by avoiding interactive motion
commands in ledger-mode.

Fix: #8376
This commit is contained in:
Henrik Lissner
2025-06-02 14:06:10 +02:00
parent c1632fa887
commit aa6f3903d5

View File

@ -27,6 +27,20 @@
(setq mwheel-scroll-up-function #'scroll-up
mwheel-scroll-down-function #'scroll-down))))
;; HACK: good-scroll advises interactive motion commands to trigger
;; interpolated scrolling. It expects these commands to only be called
;; interactively, but there are cases (like in `ledger-mode') where they (in
;; this case, `move-end-of-line') are called programmatically where the
;; selected window's boundaries may be out of bounds for the target buffer.
;; Cue the errors.
;; REVIEW: This shold be fixed upstream.
(defadvice! +smooth-scroll--fix-out-of-bounds-error-a ()
:override #'good-scroll--point-at-top-fix-a
(save-restriction
(widen)
(<= (line-number-at-pos (max (point) (point-min)) t)
(1+ (line-number-at-pos (min (window-start) (point-max)) t)))))
(defun good-scroll--convert-line-to-step (line)
(cond ((integerp line) (* line (line-pixel-height)))
((or (null line) (memq '- line))