Skip to content

Commit

Permalink
Fix block pasting at bolp on empty line
Browse files Browse the repository at this point in the history
  • Loading branch information
tomdl89 committed May 7, 2024
1 parent 0b47905 commit 3be6279
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
19 changes: 10 additions & 9 deletions evil-common.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion evil-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand Down

0 comments on commit 3be6279

Please sign in to comment.