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

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

[nongnu] elpa/evil 1f14c5d 6/7: Replace state evil-delete-back-to-indent


From: ELPA Syncer
Subject: [nongnu] elpa/evil 1f14c5d 6/7: Replace state evil-delete-back-to-indentation
Date: Sun, 19 Dec 2021 12:57:44 -0500 (EST)

branch: elpa/evil
commit 1f14c5db2fd53667134565e6e69c7c05593a576f
Author: Tom Dalziel <tom_dl@hotmail.com>
Commit: Tom Dalziel <33435574+tomdl89@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'"



reply via email to

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