diff --git a/evil-commands.el b/evil-commands.el index ac88186f..7bd93bc3 100644 --- a/evil-commands.el +++ b/evil-commands.el @@ -1043,7 +1043,7 @@ If the scroll count is zero the command scrolls half the screen." (when (= (point-min) (line-beginning-position)) (signal 'beginning-of-buffer nil)) (when (zerop count) - (setq count (/ (window-body-height) 2))) + (setq count (/ (evil-window-visible-height) 2))) (let ((xy (evil-posn-x-y (posn-at-point)))) (condition-case nil (progn @@ -1067,7 +1067,7 @@ If the scroll count is zero the command scrolls half the screen." (setq evil-scroll-count count) (when (eobp) (signal 'end-of-buffer nil)) (when (zerop count) - (setq count (/ (window-body-height) 2))) + (setq count (/ (evil-window-visible-height) 2))) ;; BUG #660: First check whether the eob is visible. ;; In that case we do not scroll but merely move point. (if (<= (point-max) (window-end)) diff --git a/evil-common.el b/evil-common.el index b68e1cab..7f3a0cff 100644 --- a/evil-common.el +++ b/evil-common.el @@ -3980,6 +3980,18 @@ PROPERTIES is a property-list which supports the following properties: (evil-motion-state)) (switch-to-buffer-other-window buf)))) +;;; Window + +(defun evil-window-visible-height (&optional window) + "The visible height of WINDOW in lines. + +If no WINDOW is specified, use the selected one." + (let ((window (or window (selected-window)))) + (save-window-excursion + (select-window window) + (let ((current-scale (expt text-scale-mode-step text-scale-mode-amount))) + (round (/ (window-body-height) current-scale)))))) + (provide 'evil-common) ;;; evil-common.el ends here