aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Dalziel <tom_dl@hotmail.com>2024-05-07 23:35:51 +0200
committerTom Dalziel <33435574+tomdl89@users.noreply.github.com>2024-05-13 23:18:04 +0200
commit8a06c5cb30175282c6e934c6d40020cedf4d4623 (patch)
treef6b7810f9a3ab3e4ff89048e297c09ebd984da8a
parent0b25d3c72479527c6531742611b58e142388514e (diff)
Fix block pasting at bolp on empty line
-rw-r--r--evil-common.el19
-rw-r--r--evil-tests.el22
2 files changed, 30 insertions, 11 deletions
diff --git a/evil-common.el b/evil-common.el
index d2e9d29..7f60bdf 100644
--- a/evil-common.el
+++ b/evil-common.el
@@ -2441,12 +2441,15 @@ The tracked insertion is set to `evil-last-insertion'."
(defun evil-yank-block-handler (lines)
"Insert the current text as block."
- (let ((count (or evil-paste-count 1))
- (col (if (eq this-command 'evil-paste-after)
- (1+ (current-column))
- (current-column)))
- (opoint (point))
- (first t))
+ (let* ((count (or evil-paste-count 1))
+ shifted-forward
+ (col (if (and (eq this-command 'evil-paste-after)
+ (not (and (bolp) (eolp)))
+ (setq shifted-forward t))
+ (1+ (current-column))
+ (current-column)))
+ (opoint (point))
+ (first t))
(dolist (line lines)
;; maybe we have to insert a new line at eob
(if first
@@ -2485,9 +2488,7 @@ The tracked insertion is set to `evil-last-insertion'."
(if evil--cursor-after
(backward-char)
(goto-char opoint)
- (when (and (eq this-command 'evil-paste-after)
- (not (eolp)))
- (forward-char)))))
+ (when shifted-forward (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 1bcdc81..75b00ea 100644
--- a/evil-tests.el
+++ b/evil-tests.el
@@ -3250,7 +3250,6 @@ word3[]"))
(evil-test-buffer
"[a]aaaaa\nbbbbb\ncccc"
("\C-v" "2j" "$" "\"xy" "G" "o" [escape] "\"xp")
- ;; TODO will fail because it inserts a left col of spaces
"aaaaaa\nbbbbb\ncccc\n[a]aaaaa\nbbbbb\ncccc")))
(ert-deftest evil-test-last-insert-register ()
@@ -7528,7 +7527,26 @@ Tiny "))
"
("\C-vfcjd")
"[b]c
-")))
+"))
+ (ert-info ("Pasting visual block")
+ (evil-test-buffer
+ "alpha [b]ravo charlie
+delta echo foxtrot
+golf hotel india
+juliet kilo mike"
+ ("\C-v" "jje" "y" "$" "p")
+ "alpha bravo charlie[b]rav
+delta echo foxtrot echo
+golf hotel india otel
+juliet kilo mike"
+ ("G" "o" [escape] "p")
+ "alpha bravo charliebrav
+delta echo foxtrot echo
+golf hotel india otel
+juliet kilo mike
+[b]rav
+echo
+otel")))
(ert-deftest evil-test-visual-restore ()
"Test restoring a previous selection"