From 5da6ef06971d8330a55b9be2b794399f36f4b79e Mon Sep 17 00:00:00 2001 From: Tom Dalziel <33435574+tomdl89@users.noreply.github.com> Date: Mon, 3 Jan 2022 14:32:27 +0100 Subject: Fix #1557 (ensure-column fix) (#1560) --- evil-common.el | 5 +++-- evil-tests.el | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/evil-common.el b/evil-common.el index 8c5b822..f4c882e 100644 --- a/evil-common.el +++ b/evil-common.el @@ -985,7 +985,8 @@ See also `evil-save-goal-column'." (eolp)))) (defmacro evil-ensure-column (&rest body) - "Execute BODY as if it is a `next-line' command, insofar as it tracks column. + "Execute BODY so that column after execution is correct. +If `evil-start-of-line' is nil, treat BODY as if it were a `next-line' command. This mostly copies the approach of Emacs' `line-move-1', but is modified so it is more compatible with evil's notions of eol & tracking." (declare (indent defun) @@ -995,7 +996,7 @@ so it is more compatible with evil's notions of eol & tracking." (setq temporary-goal-column (+ (car temporary-goal-column) (cdr temporary-goal-column)))))) `(progn - (setq this-command 'next-line) + (unless evil-start-of-line (setq this-command 'next-line)) ,normalize-temporary-goal-column (if (not (memq last-command '(next-line previous-line))) (setq temporary-goal-column diff --git a/evil-tests.el b/evil-tests.el index be03b05..53f5776 100644 --- a/evil-tests.el +++ b/evil-tests.el @@ -3294,6 +3294,13 @@ The longest lin[e]" Average line The longest line"))) + (ert-info ("evil-goto-line respects evil-start-of-line") + (let ((evil-start-of-line t)) + (evil-test-buffer + "foo\n[b]ar" + ("$ggj") + "foo\n[b]ar"))) + (ert-info ("N% (`evil-jump-item' with count) can preserve column") (let ((evil-start-of-line nil)) (evil-test-buffer -- cgit v1.0