Skip to content

Commit

Permalink
Don't mutate register when stripping test props during paste
Browse files Browse the repository at this point in the history
Fixes an issue noticed while triaging #1894
  • Loading branch information
tomdl89 committed Apr 30, 2024
1 parent fe44a56 commit 8d3da0c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
14 changes: 8 additions & 6 deletions evil-commands.el
Original file line number Diff line number Diff line change
Expand Up @@ -2249,9 +2249,10 @@ The return value is the yanked text."
(let ((evil-kill-on-visual-paste (not evil-kill-on-visual-paste)))
(evil-visual-paste count register))
(evil-with-undo
(let* ((text (if register
(evil-get-register register)
(current-kill 0)))
(let* ((text (copy-sequence
(if register
(evil-get-register register)
(current-kill 0))))
(yank-handler (or yank-handler
(when (stringp text)
(car-safe (get-text-property
Expand Down Expand Up @@ -2305,9 +2306,10 @@ The return value is the yanked text."
(if (evil-visual-state-p)
(evil-visual-paste count register)
(evil-with-undo
(let* ((text (if register
(evil-get-register register)
(current-kill 0)))
(let* ((text (copy-sequence
(if register
(evil-get-register register)
(current-kill 0))))
(yank-handler (or yank-handler
(when (stringp text)
(car-safe (get-text-property
Expand Down
12 changes: 11 additions & 1 deletion evil-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -2750,7 +2750,17 @@ This bufferThis bufferThis buffe[r];; and for Lisp evaluation."))
("p")
";; This buffer is for notes you don't want to save.[;];
;; If you want to create a file, visit that file wi;; th C-x C-f,
;; then enter the text in that file's own buffer. ;;")))
;; then enter the text in that file's own buffer. ;;"))
(ert-info ("Don't mutate register when stripping test props")
(let (indent-tabs-mode)
(evil-test-buffer
"[a]aaaaaaaaaaaa
bbbbbbbb
cccc"
("\C-vG$yA " "\C-r\"" [escape] "up")
"aaaaaaaaaaaaa[a]aaaaaaaaaaaa
bbbbbbbb bbbbbbbb
cccc cccc"))))

(ert-deftest evil-test-paste-after ()
"Test `evil-paste-after'"
Expand Down

0 comments on commit 8d3da0c

Please sign in to comment.