Skip to content

Commit

Permalink
Account for large values of scroll-margin in evil-window-top+bottom
Browse files Browse the repository at this point in the history
  • Loading branch information
tomdl89 committed Dec 12, 2024
1 parent b7ab384 commit e783fc2
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions evil-commands.el
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -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)
Expand Down

0 comments on commit e783fc2

Please sign in to comment.