Skip to content

Commit ebc7854

Browse files
committed
Account for large values of scroll-margin in evil-window-top+bottom
1 parent b7ab384 commit ebc7854

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

evil-commands.el

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,12 @@ In Insert state, insert a newline and indent."
889889
(evil-ensure-column
890890
(move-to-window-line
891891
(max (or count 0)
892-
(if (= (point-min) (window-start)) 0 scroll-margin)))))
892+
(if (or (zerop scroll-margin)
893+
(= (point-min) (window-start))
894+
(< (count-screen-lines (window-start) (point))
895+
scroll-margin))
896+
0
897+
scroll-margin)))))
893898

894899
(evil-define-motion evil-window-middle ()
895900
"Move the cursor to the middle line in the window."
@@ -902,7 +907,13 @@ In Insert state, insert a newline and indent."
902907
:jump t
903908
:type line
904909
(evil-ensure-column
905-
(move-to-window-line (- (max (or count 1) (1+ scroll-margin))))))
910+
(move-to-window-line
911+
(- (max (or count 1)
912+
(if (or (zerop scroll-margin)
913+
(< (count-screen-lines (point) (window-end))
914+
scroll-margin))
915+
1
916+
(1+ scroll-margin)))))))
906917

907918
;; scrolling
908919
(evil-define-command evil-scroll-line-up (count)

0 commit comments

Comments
 (0)