aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Dalziel <tom_dl@hotmail.com>2024-04-02 19:38:37 +0200
committerTom Dalziel <tom_dl@hotmail.com>2024-04-02 19:38:37 +0200
commit88d073c9d03ca223564e7e8589f44ecc87c98153 (patch)
tree6f2f0402fe3dc958f2d4dfc3ccd16e47abeb7892
parent004ac4e0cd766d49d48d53270e9c0c080ad9f173 (diff)
Fix point placement after D and C in normal state
Bug since 476f5fbcf1288c5a46a6ba35efe0b8dd1e4dd0ec Thanks to @axelf4 for spotting.
-rw-r--r--evil-commands.el13
-rw-r--r--evil-tests.el32
2 files changed, 38 insertions, 7 deletions
diff --git a/evil-commands.el b/evil-commands.el
index 150ac04..7938b93 100644
--- a/evil-commands.el
+++ b/evil-commands.el
@@ -1530,12 +1530,13 @@ Save in REGISTER or in the kill-ring with YANK-HANDLER."
(last-command 'next-line))
(evil-delete beg end 'block register yank-handler))
(evil-delete beg end type register yank-handler)
- (evil-first-non-blank)
- (when (and (not evil-start-of-line) evil-operator-start-col)
- (move-to-column (if (and (eq most-positive-fixnum temporary-goal-column)
- (memq last-command '(next-line previous-line)))
- temporary-goal-column
- evil-operator-start-col))))))
+ (when (eq 'line type)
+ (evil-first-non-blank)
+ (when (and (not evil-start-of-line) evil-operator-start-col)
+ (move-to-column (if (and (eq most-positive-fixnum temporary-goal-column)
+ (memq last-command '(next-line previous-line)))
+ temporary-goal-column
+ evil-operator-start-col)))))))
(evil-define-operator evil-delete-whole-line
(beg end type register yank-handler)
diff --git a/evil-tests.el b/evil-tests.el
index 8ca961f..259c6ff 100644
--- a/evil-tests.el
+++ b/evil-tests.el
@@ -2166,7 +2166,37 @@ ine3 line3 line3 l\n"))
;; This is line three"
("v$D")
";; This is line one
-;; This is line three")))
+;; This is line three"))
+ (ert-info ("Deletion in normal state leaves point in the right place")
+ (evil-test-buffer
+ "alpha b[r]avo charlie\ndelta echo foxtrot\ngolf hotel india"
+ (should (not evil-start-of-line))
+ ("D")
+ "alpha [b]\ndelta echo foxtrot\ngolf hotel india"
+ ("/echo" [return] "C" "newtext" [escape])
+ "alpha b\ndelta newtex[t]\ngolf hotel india")
+ (let ((evil-start-of-line t))
+ (evil-test-buffer
+ "alpha b[r]avo charlie\ndelta echo foxtrot\ngolf hotel india"
+ ("D")
+ "alpha [b]\ndelta echo foxtrot\ngolf hotel india"
+ ("/echo" [return] "C" "newtext" [escape])
+ "alpha b\ndelta newtex[t]\ngolf hotel india")))
+ (ert-info ("Line deletion in visual state leaves point in the right place")
+ (evil-test-buffer
+ "alpha [b]ravo charlie\ndelta echo foxtrot\ngolf hotel india"
+ (should (not evil-start-of-line))
+ ("vD")
+ "delta [e]cho foxtrot\ngolf hotel india"
+ ("vX")
+ "golf h[o]tel india")
+ (let ((evil-start-of-line t))
+ (evil-test-buffer
+ "alpha [b]ravo charlie\ndelta echo foxtrot\ngolf hotel india"
+ ("vD")
+ "[d]elta echo foxtrot\ngolf hotel india"
+ ("vX")
+ "[g]olf hotel india"))))
(ert-deftest evil-test-delete-folded ()
"Test `evil-delete' on folded lines."