From e783fc200153063401be28b11dfaf76fdde442f8 Mon Sep 17 00:00:00 2001 From: Tom Dalziel Date: Fri, 13 Dec 2024 00:21:21 +0100 Subject: [PATCH] Account for large values of scroll-margin in evil-window-top+bottom --- evil-commands.el | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/evil-commands.el b/evil-commands.el index 4f6b7313..3b07e638 100644 --- a/evil-commands.el +++ b/evil-commands.el @@ -889,7 +889,12 @@ In Insert state, insert a newline and indent." (evil-ensure-column (move-to-window-line (max (or count 0) - (if (= (point-min) (window-start)) 0 scroll-margin))))) + (if (or (zerop scroll-margin) + (= (point-min) (window-start)) + (< (count-screen-lines (window-start) (point)) + scroll-margin)) + 0 + scroll-margin))))) (evil-define-motion evil-window-middle () "Move the cursor to the middle line in the window." @@ -902,7 +907,13 @@ In Insert state, insert a newline and indent." :jump t :type line (evil-ensure-column - (move-to-window-line (- (max (or count 1) (1+ scroll-margin)))))) + (move-to-window-line + (- (max (or count 1) + (if (or (zerop scroll-margin) + (< (count-screen-lines (point) (window-end)) + scroll-margin)) + 1 + (1+ scroll-margin))))))) ;; scrolling (evil-define-command evil-scroll-line-up (count)