;; If a small number of lines from the previous message are
;; visible, realign so that the top of the current message is at
;; the top of the screen.
- (if (< (count-lines (window-start) (notmuch-show-message-top))
- next-screen-context-lines)
+ (if (<= (count-screen-lines (window-start) start-of-message)
+ next-screen-context-lines)
(progn
(goto-char (notmuch-show-message-top))
(notmuch-show-message-adjust)))