diff --git a/evil-common.el b/evil-common.el index d2e9d29b..7f60bdfb 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 1bcdc815..75b00ea1 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"