aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Dalziel <tom_dl@hotmail.com>2022-11-04 23:13:42 +0000
committerTom Dalziel <33435574+tomdl89@users.noreply.github.com>2022-11-05 01:18:35 +0100
commitc59f2c09c63de5f001c19f8513a19dfc72858e75 (patch)
tree565e5d1ab07ba37666c62b8e6862c9ab53521f87
parentf9218169f1f39225e9f631209d285bb7af50c8fd (diff)
gp & gP linewise & blockwise
-rw-r--r--evil-commands.el22
-rw-r--r--evil-common.el13
-rw-r--r--evil-tests.el11
-rw-r--r--evil-vars.el3
4 files changed, 37 insertions, 12 deletions
diff --git a/evil-commands.el b/evil-commands.el
index fca933b..57dc58b 100644
--- a/evil-commands.el
+++ b/evil-commands.el
@@ -2206,6 +2206,11 @@ The return value is the yanked text."
(when (and evil-move-cursor-back
(> (length text) 0))
(backward-char))))
+ (when evil--cursor-after
+ (if (eq 'evil-yank-line-handler yank-handler)
+ (ignore-errors (evil-next-line-first-non-blank 1))
+ (evil-forward-char 1 nil t))
+ (setq evil--cursor-after nil))
;; no paste-pop after pasting from a register
(when register
(setq evil-last-paste nil))
@@ -2258,6 +2263,11 @@ The return value is the yanked text."
(evil-set-marker ?\] (1- (point)))
(when (evil-normal-state-p)
(evil-move-cursor-back)))))
+ (when evil--cursor-after
+ (if (eq 'evil-yank-line-handler yank-handler)
+ (ignore-errors (evil-next-line-first-non-blank 1))
+ (evil-forward-char 1 nil t))
+ (setq evil--cursor-after nil))
(when register
(setq evil-last-paste nil))
(and (> (length text) 0) text)))))
@@ -2268,9 +2278,9 @@ The return value is the yanked text."
leave the cursor just after the new text."
:suppress-operator t
(interactive "*P<x>")
- (setq count (prefix-numeric-value count))
- (evil-paste-before count register yank-handler)
- (evil-forward-char 1 nil t))
+ (setq count (prefix-numeric-value count)
+ evil--cursor-after t)
+ (evil-paste-before count register yank-handler))
(evil-define-command evil-paste-after-cursor-after
(count &optional register yank-handler)
@@ -2278,9 +2288,9 @@ leave the cursor just after the new text."
leave the cursor just after the new text."
:suppress-operator t
(interactive "*P<x>")
- (setq count (prefix-numeric-value count))
- (evil-paste-after count register yank-handler)
- (evil-forward-char 1 nil t))
+ (setq count (prefix-numeric-value count)
+ evil--cursor-after t)
+ (evil-paste-after count register yank-handler))
(defun evil-insert-for-yank-at-col (startcol _endcol string count)
"Insert STRING at STARTCOL."
diff --git a/evil-common.el b/evil-common.el
index 349deff..ba9f137 100644
--- a/evil-common.el
+++ b/evil-common.el
@@ -2687,7 +2687,8 @@ The tracked insertion is set to `evil-last-insertion'."
(mark t)
(point)))
(evil-move-mark (1+ (mark t)))
- (evil-exchange-point-and-mark)
+ (unless evil--cursor-after
+ (evil-exchange-point-and-mark))
(back-to-indentation))
(t
(insert text)))))
@@ -2738,10 +2739,12 @@ The tracked insertion is set to `evil-last-insertion'."
(* count (length (car lines))))) ; number of colums
(evil-set-marker ?\[ opoint)
(evil-set-marker ?\] (1- epoint))
- (goto-char opoint)
- (when (and (eq this-command 'evil-paste-after)
- (not (eolp)))
- (forward-char))))
+ (if evil--cursor-after
+ (goto-char (1- epoint))
+ (goto-char opoint)
+ (when (and (eq this-command 'evil-paste-after)
+ (not (eolp)))
+ (forward-char)))))
(defun evil-delete-yanked-rectangle (nrows ncols)
"Special function to delete the block yanked by a previous paste command.
diff --git a/evil-tests.el b/evil-tests.el
index 2e069af..276eb7b 100644
--- a/evil-tests.el
+++ b/evil-tests.el
@@ -3154,7 +3154,16 @@ word3[]"))
("2F " "gP")
"alphaalpha[ ]bravo alphacharlie"
("l" "ve" "gp")
- "alphaalpha alpha[ ]alphacharlie")))
+ "alphaalpha alpha[ ]alphacharlie"))
+ (ert-info ("gp linewise")
+ (evil-test-buffer
+ "[a]lpha line\nbravo line\ncharlie line\ndelta line\necho line"
+ ("2yy" "2j")
+ "alpha line\nbravo line\n[c]harlie line\ndelta line\necho line"
+ ("gp")
+ "alpha line\nbravo line\ncharlie line\nalpha line\nbravo line\n[d]elta line\necho line"
+ (".")
+ "alpha line\nbravo line\ncharlie line\nalpha line\nbravo line\ndelta line\nalpha line\nbravo line\necho line")))
(ert-deftest evil-test-ex-put ()
"evil-ex-put inserts text linewise, regardless of yank-handler"
diff --git a/evil-vars.el b/evil-vars.el
index 74aeb51..c8ec51a 100644
--- a/evil-vars.el
+++ b/evil-vars.el
@@ -1683,6 +1683,9 @@ not deleted and not yanked to a specific register.")
(defvar evil-paste-count nil
"The count argument of the current paste command.")
+(defvar evil--cursor-after nil
+ "Internal flag for gp & gP.")
+
(defvar evil-temporary-undo nil
"When undo is disabled in current buffer.
Certain commands depending on undo use this variable