emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/evil 8a06c5cb30 2/2: Fix block pasting at bolp on empty li


From: ELPA Syncer
Subject: [nongnu] elpa/evil 8a06c5cb30 2/2: Fix block pasting at bolp on empty line
Date: Mon, 13 May 2024 18:59:34 -0400 (EDT)

branch: elpa/evil
commit 8a06c5cb30175282c6e934c6d40020cedf4d4623
Author: Tom Dalziel <tom_dl@hotmail.com>
Commit: Tom Dalziel <33435574+tomdl89@users.noreply.github.com>

    Fix block pasting at bolp on empty line
---
 evil-common.el | 19 ++++++++++---------
 evil-tests.el  | 22 ++++++++++++++++++++--
 2 files changed, 30 insertions(+), 11 deletions(-)

diff --git a/evil-common.el b/evil-common.el
index d2e9d29bcd..7f60bdfb3b 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 1bcdc81546..75b00ea182 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"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]