branch: elpa/evil commit 1f14c5db2fd53667134565e6e69c7c05593a576f Author: Tom Dalziel <tom...@hotmail.com> Commit: Tom Dalziel <33435574+tomd...@users.noreply.github.com>
Replace state evil-delete-back-to-indentation --- evil-commands.el | 19 +++++++++++-------- evil-tests.el | 11 +++++++++-- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/evil-commands.el b/evil-commands.el index d34abfd..166bb71 100644 --- a/evil-commands.el +++ b/evil-commands.el @@ -1594,14 +1594,17 @@ If point is before the first non-whitespace character of a current line then delete from the point to the beginning of the current line. If point is on the beginning of the line, behave according to `evil-backspace-join-lines'." - (if (bolp) - (evil-delete-backward-char-and-join 1) - (delete-region (if (<= (current-column) (current-indentation)) - (line-beginning-position) - (save-excursion - (evil-first-non-blank) - (point))) - (point)))) + (let ((beg (if (<= (current-column) (current-indentation)) + (line-beginning-position) + (save-excursion + (evil-first-non-blank) + (point))))) + (cond + ((and (bolp) (evil-replace-state-p)) (evil-replace-backspace)) + ((bolp) (evil-delete-backward-char-and-join 1)) + ((evil-replace-state-p) (while (< beg (point)) + (evil-replace-backspace))) + (t (delete-region beg (point)))))) (defun evil-ex-delete-or-yank (should-delete beg end type register count yank-handler) "Execute evil-delete or evil-yank on the given region. diff --git a/evil-tests.el b/evil-tests.el index 2cd80bd..8212efc 100644 --- a/evil-tests.el +++ b/evil-tests.el @@ -2111,7 +2111,7 @@ ine3 line3 line3 l\n"))) "alpha [b]ravo charlie delta"))) (ert-deftest evil-test-delete-back-to-indentation () - "Test `evil-delete-back-to-indentation' in insert state." + "Test `evil-delete-back-to-indentation' in insert & replace states." :tags '(evil) (let ((evil-backspace-join-lines t)) (evil-test-buffer @@ -2131,7 +2131,14 @@ ine3 line3 line3 l\n"))) (progn (execute-kbd-macro "i") (call-interactively #'evil-delete-back-to-indentation))) - "abc def\n[k]l\n"))) + "abc def\n[k]l\n")) + (ert-info ("Delete back to indentation in replace state") + (evil-test-buffer + " alpha [b]ravo charlie" + ("R" "delta") + " alpha delta[ ]charlie" + (evil-delete-back-to-indentation) + " [a]lpha bravo charlie"))) (ert-deftest evil-test-change () "Test `evil-change'"