From 9d07b8e323427952cd6215ed61b08a6149ec4197 Mon Sep 17 00:00:00 2001 From: James Cherti <60946298+jamescherti@users.noreply.github.com> Date: Thu, 7 Nov 2024 10:52:19 -0500 Subject: [PATCH] Fix issue: No visible text when cursor is moved to the end of buffer This pull request fixes an issue where using `(evil-goto-line nil)` to move the cursor to the end of the buffer would result in no visible text. This patch draws inspiration from the built-in `(end-of-buffer)` function, which does not exhibit the same issue as calling `(evil-goto-line nil)`. --- evil-commands.el | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/evil-commands.el b/evil-commands.el index 2e3a26a2..8c29db41 100644 --- a/evil-commands.el +++ b/evil-commands.el @@ -254,7 +254,14 @@ 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))) + ;; If the end of the buffer is not already on the screen, scroll in + ;; a special way to position it near the bottom. + (overlay-recenter (point)) + (recenter -1))) (goto-char (point-min)) (forward-line (1- count)))))