Skip to content

Commit

Permalink
Fix point placement after D and C in normal state
Browse files Browse the repository at this point in the history
Bug since 476f5fb
Thanks to @axelf4 for spotting.
  • Loading branch information
tomdl89 committed Apr 2, 2024
1 parent 004ac4e commit 88d073c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
13 changes: 7 additions & 6 deletions evil-commands.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
32 changes: 31 additions & 1 deletion evil-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down

0 comments on commit 88d073c

Please sign in to comment.