mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-01 12:17:25 -05:00
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:
@ -27,6 +27,20 @@
|
|||||||
(setq mwheel-scroll-up-function #'scroll-up
|
(setq mwheel-scroll-up-function #'scroll-up
|
||||||
mwheel-scroll-down-function #'scroll-down))))
|
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)
|
(defun good-scroll--convert-line-to-step (line)
|
||||||
(cond ((integerp line) (* line (line-pixel-height)))
|
(cond ((integerp line) (* line (line-pixel-height)))
|
||||||
((or (null line) (memq '- line))
|
((or (null line) (memq '- line))
|
||||||
|
Reference in New Issue
Block a user