Skip to content

Commit 88d073c

Browse files
committed
Fix point placement after D and C in normal state
Bug since 476f5fb Thanks to @axelf4 for spotting.
1 parent 004ac4e commit 88d073c

File tree

2 files changed

+38
-7
lines changed

2 files changed

+38
-7
lines changed

evil-commands.el

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,12 +1530,13 @@ Save in REGISTER or in the kill-ring with YANK-HANDLER."
15301530
(last-command 'next-line))
15311531
(evil-delete beg end 'block register yank-handler))
15321532
(evil-delete beg end type register yank-handler)
1533-
(evil-first-non-blank)
1534-
(when (and (not evil-start-of-line) evil-operator-start-col)
1535-
(move-to-column (if (and (eq most-positive-fixnum temporary-goal-column)
1536-
(memq last-command '(next-line previous-line)))
1537-
temporary-goal-column
1538-
evil-operator-start-col))))))
1533+
(when (eq 'line type)
1534+
(evil-first-non-blank)
1535+
(when (and (not evil-start-of-line) evil-operator-start-col)
1536+
(move-to-column (if (and (eq most-positive-fixnum temporary-goal-column)
1537+
(memq last-command '(next-line previous-line)))
1538+
temporary-goal-column
1539+
evil-operator-start-col)))))))
15391540

15401541
(evil-define-operator evil-delete-whole-line
15411542
(beg end type register yank-handler)

evil-tests.el

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2166,7 +2166,37 @@ ine3 line3 line3 l\n"))
21662166
;; This is line three"
21672167
("v$D")
21682168
";; This is line one
2169-
;; This is line three")))
2169+
;; This is line three"))
2170+
(ert-info ("Deletion in normal state leaves point in the right place")
2171+
(evil-test-buffer
2172+
"alpha b[r]avo charlie\ndelta echo foxtrot\ngolf hotel india"
2173+
(should (not evil-start-of-line))
2174+
("D")
2175+
"alpha [b]\ndelta echo foxtrot\ngolf hotel india"
2176+
("/echo" [return] "C" "newtext" [escape])
2177+
"alpha b\ndelta newtex[t]\ngolf hotel india")
2178+
(let ((evil-start-of-line t))
2179+
(evil-test-buffer
2180+
"alpha b[r]avo charlie\ndelta echo foxtrot\ngolf hotel india"
2181+
("D")
2182+
"alpha [b]\ndelta echo foxtrot\ngolf hotel india"
2183+
("/echo" [return] "C" "newtext" [escape])
2184+
"alpha b\ndelta newtex[t]\ngolf hotel india")))
2185+
(ert-info ("Line deletion in visual state leaves point in the right place")
2186+
(evil-test-buffer
2187+
"alpha [b]ravo charlie\ndelta echo foxtrot\ngolf hotel india"
2188+
(should (not evil-start-of-line))
2189+
("vD")
2190+
"delta [e]cho foxtrot\ngolf hotel india"
2191+
("vX")
2192+
"golf h[o]tel india")
2193+
(let ((evil-start-of-line t))
2194+
(evil-test-buffer
2195+
"alpha [b]ravo charlie\ndelta echo foxtrot\ngolf hotel india"
2196+
("vD")
2197+
"[d]elta echo foxtrot\ngolf hotel india"
2198+
("vX")
2199+
"[g]olf hotel india"))))
21702200

21712201
(ert-deftest evil-test-delete-folded ()
21722202
"Test `evil-delete' on folded lines."

0 commit comments

Comments
 (0)