Skip to content

Commit 6ca32ca

Browse files
committed
Fix pasting charwise text onto linewise selection
1 parent 792e1d1 commit 6ca32ca

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

evil-commands.el

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2356,6 +2356,11 @@ leave the cursor just after the new text."
23562356
(setq beg evil-visual-beginning
23572357
end evil-visual-end
23582358
type (evil-visual-type))
2359+
;; When pasting charwise text into linewise selection, keep trailing NL
2360+
(when (and text end
2361+
(eq 'line type)
2362+
(not (eq ?\n (aref text (1- (length text))))))
2363+
(cl-decf end))
23592364
(evil-visual-rotate 'upper-left)
23602365
(evil-delete beg end type (unless evil-kill-on-visual-paste ?_))
23612366
(when (and (eq yank-handler #'evil-yank-line-handler)

evil-tests.el

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3081,7 +3081,7 @@ word3[]"))
30813081
("yiwyywyiw^j")
30823082
"word1a word1b word1c\n[w]ord2a word2b\nword3a word3b word3c word3d\n"
30833083
("Vp")
3084-
"word1a word1b word1c\nword1[b]word3a word3b word3c word3d\n"))
3084+
"word1a word1b word1c\nword1[b]\nword3a word3b word3c word3d\n"))
30853085
(ert-info ("Visual-line paste, char paste, line pop")
30863086
(evil-test-buffer
30873087
"[w]ord1a word1b word1c\nword2a word2b\nword3a word3b word3c word3d\n"
@@ -3095,7 +3095,7 @@ word3[]"))
30953095
("yiwyywyiw^j")
30963096
"word1a word1b word1c\n[w]ord2a word2b\nword3a word3b word3c word3d\n"
30973097
("Vp\C-p\C-p")
3098-
"word1a word1b word1c\nword1[a]word3a word3b word3c word3d\n")))
3098+
"word1a word1b word1c\nword1[a]\nword3a word3b word3c word3d\n")))
30993099

31003100
(ert-deftest evil-test-register ()
31013101
"Test yanking and pasting to and from register."

0 commit comments

Comments
 (0)