aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Dalziel <tom_dl@hotmail.com>2022-01-06 20:38:46 +0100
committerTom Dalziel <33435574+tomdl89@users.noreply.github.com>2022-01-07 13:18:49 +0100
commit8afda6f6493a7f32c31d0e948e65ade06e17d1be (patch)
tree984d2fd606a4610321b4e5ac722ad0309caa50e9
parent62df6ee1c37cd4d7a27fc07c305b7486ea990efe (diff)
Fix visual-paste-pop tests
-rw-r--r--evil-commands.el4
-rw-r--r--evil-common.el3
-rw-r--r--evil-tests.el17
-rw-r--r--evil-vars.el3
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
+<alpha bravo\ncharlie delta\n>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.")