From 8afda6f6493a7f32c31d0e948e65ade06e17d1be Mon Sep 17 00:00:00 2001 From: Tom Dalziel Date: Thu, 6 Jan 2022 20:38:46 +0100 Subject: Fix visual-paste-pop tests --- evil-commands.el | 4 +++- evil-common.el | 3 +++ evil-tests.el | 17 ++++++++++++++++- evil-vars.el | 3 +++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/evil-commands.el b/evil-commands.el index 4055e89..fc1d478 100644 --- a/evil-commands.el +++ b/evil-commands.el @@ -2243,7 +2243,9 @@ The return value is the yanked text." (when evil-kill-on-visual-paste (current-kill -1)) ;; Ensure that gv can restore visually pasted area... - (setq evil-visual-mark (evil-get-marker ?\[ t) + (setq evil-visual-previous-mark evil-visual-mark + evil-visual-mark (evil-get-marker ?\[ t) + evil-visual-previous-point evil-visual-point evil-visual-point (evil-get-marker ?\] t)) ;; mark the last paste as visual-paste (setq evil-last-paste diff --git a/evil-common.el b/evil-common.el index f4c882e..1c07d28 100644 --- a/evil-common.el +++ b/evil-common.el @@ -2764,6 +2764,9 @@ is negative this is a more recent kill." (unless evil-last-paste (user-error "Previous paste command used a register")) (evil-undo-pop) + (when (eq last-command 'evil-visual-paste) + (evil-swap evil-visual-previous-mark evil-visual-mark) + (evil-swap evil-visual-previous-point evil-visual-point)) (goto-char (nth 2 evil-last-paste)) (setq this-command (nth 0 evil-last-paste)) ;; use temporary kill-ring, so the paste cannot modify it diff --git a/evil-tests.el b/evil-tests.el index 28cde32..0c56862 100644 --- a/evil-tests.el +++ b/evil-tests.el @@ -7108,7 +7108,22 @@ if no previous selection") ;;[ ]>and for Lisp evaluation." ([escape] "gv") "<;; This buffer is for notes, -;;[ ]>and for Lisp evaluation."))) +;;[ ]>and for Lisp evaluation.") + (ert-info ("After paste shifts initially selected text") + (evil-test-buffer + :visual block + "<1\n2\n[3]>" + ("yP") + "[1]1\n22\n33" + ("gvr*") + "[*]1\n*2\n*3"))) + (ert-info ("Restore linewise visually-pasted selection") + (evil-test-buffer + "[a]lpha bravo\ncharlie delta +echo foxtrot\ngolf hotel" + ("2yy" "++" "Vp" "gv") + "alpha bravo\ncharlie delta +golf hotel"))) ;;; Replace state diff --git a/evil-vars.el b/evil-vars.el index 5e2cb93..3887bb4 100644 --- a/evil-vars.el +++ b/evil-vars.el @@ -1654,6 +1654,9 @@ instead of `buffer-undo-list'.") (evil-define-local-var evil-visual-point nil "The position of point in Visual state, a marker.") +(evil-define-local-var evil-visual-previous-point nil + "The position of point before Visual state, a marker.") + (evil-define-local-var evil-visual-mark nil "The position of mark in Visual state, a marker.") -- cgit v1.0