diff options
| author | Tom Dalziel <tom_dl@hotmail.com> | 2024-01-04 11:59:38 +0100 |
|---|---|---|
| committer | Tom Dalziel <33435574+tomdl89@users.noreply.github.com> | 2024-01-04 11:15:43 +0000 |
| commit | 6ca32ca05eef41c3bc3d9cc66fc052741250bc3a (patch) | |
| tree | ca5c82f079bd0cc1f71c69e77d5feae5a9532bcc | |
| parent | 792e1d11f26b9dd7aa047d66671f38192cdace03 (diff) | |
Fix pasting charwise text onto linewise selection
| -rw-r--r-- | evil-commands.el | 5 | ||||
| -rw-r--r-- | evil-tests.el | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/evil-commands.el b/evil-commands.el index 21a2527..286cf94 100644 --- a/evil-commands.el +++ b/evil-commands.el @@ -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) diff --git a/evil-tests.el b/evil-tests.el index 84a779e..09569f1 100644 --- a/evil-tests.el +++ b/evil-tests.el @@ -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" @@ -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." |
