Skip to content

Commit

Permalink
Fix pasting charwise text onto linewise selection
Browse files Browse the repository at this point in the history
  • Loading branch information
tomdl89 committed Jan 4, 2024
1 parent 792e1d1 commit 6ca32ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions evil-commands.el
Original file line number Diff line number Diff line change
Expand Up @@ -2356,6 +2356,11 @@ leave the cursor just after the new text."
(setq beg evil-visual-beginning
end evil-visual-end
type (evil-visual-type))
;; When pasting charwise text into linewise selection, keep trailing NL
(when (and text end
(eq 'line type)
(not (eq ?\n (aref text (1- (length text))))))
(cl-decf end))
(evil-visual-rotate 'upper-left)
(evil-delete beg end type (unless evil-kill-on-visual-paste ?_))
(when (and (eq yank-handler #'evil-yank-line-handler)
Expand Down
4 changes: 2 additions & 2 deletions evil-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -3081,7 +3081,7 @@ word3[]"))
("yiwyywyiw^j")
"word1a word1b word1c\n[w]ord2a word2b\nword3a word3b word3c word3d\n"
("Vp")
"word1a word1b word1c\nword1[b]word3a word3b word3c word3d\n"))
"word1a word1b word1c\nword1[b]\nword3a word3b word3c word3d\n"))
(ert-info ("Visual-line paste, char paste, line pop")
(evil-test-buffer
"[w]ord1a word1b word1c\nword2a word2b\nword3a word3b word3c word3d\n"
Expand All @@ -3095,7 +3095,7 @@ word3[]"))
("yiwyywyiw^j")
"word1a word1b word1c\n[w]ord2a word2b\nword3a word3b word3c word3d\n"
("Vp\C-p\C-p")
"word1a word1b word1c\nword1[a]word3a word3b word3c word3d\n")))
"word1a word1b word1c\nword1[a]\nword3a word3b word3c word3d\n")))

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

0 comments on commit 6ca32ca

Please sign in to comment.