aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Dalziel <33435574+tomdl89@users.noreply.github.com>2022-01-03 14:32:27 +0100
committerGitHub <noreply@github.com>2022-01-03 14:32:27 +0100
commit5da6ef06971d8330a55b9be2b794399f36f4b79e (patch)
tree9e0c836feed00bde79c7bd3a7bee35b8981c8618
parent652d726ebd8cdfcac3e97a801721f33b5b832a0a (diff)
Fix #1557 (ensure-column fix) (#1560)
-rw-r--r--evil-common.el5
-rw-r--r--evil-tests.el7
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