Skip to content

Commit

Permalink
Fix issue: No visible text when cursor is moved to the end of the buffer
Browse files Browse the repository at this point in the history
When the user sets `scroll-conservatively` to a value greater than 100,
moving the cursor to `(point-max)` with `(evil-goto-line nil)` causes
all text to be positioned above the window start, making it invisible to
the user.

This commit resolves the issue by recentering the window in this
specific case.

While Emacs recenters the screen using `(recenter nil)` when
`scroll-conservatively` is less than or equal to 100, this behavior does
not match Vim's. To align with Vim's behavior, we use `(recenter -1)`,
regardless of the value of `scroll-conservatively`.
  • Loading branch information
jamescherti committed Nov 10, 2024
1 parent 81ec688 commit 6a4fcaf
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion evil-commands.el
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,18 @@ of the current screen line."
:type line
(evil-ensure-column
(if (null count)
(goto-char (point-max))
(progn
(goto-char (point-max))
(when (and (eq (current-buffer) (window-buffer))
(> (point) (window-end nil t)))
;; When the user sets `scroll-conservatively` to a value greater
;; than 100, moving the cursor to `(point-max)` with
;; `(evil-goto-line nil)` results in all text being located above
;; the window start, preventing the user from seeing it.
;;
;; The following addresses this issue:
(overlay-recenter (point))
(recenter -1)))
(goto-char (point-min))
(forward-line (1- count)))))

Expand Down

0 comments on commit 6a4fcaf

Please sign in to comment.