[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil 5826a88777: Fix daw deleting indentation when deletin
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil 5826a88777: Fix daw deleting indentation when deleting the only word in a line |
Date: |
Mon, 25 Jul 2022 05:58:19 -0400 (EDT) |
branch: elpa/evil
commit 5826a8877736fc734ea9da7d2bba11ef2b05032c
Author: Aaron L. Zeng <me@bcc32.com>
Commit: Tom Dalziel <33435574+tomdl89@users.noreply.github.com>
Fix daw deleting indentation when deleting the only word in a line
In vim, deleting an indented word when it's the only word on a line
will just not delete any whitespace. This applies specifically to
word objects in vim (see
https://github.com/vim/vim/blob/c7bd2f08e531f08723cdc677212a3633d11c9a97/src/textobject.c#L809),
and not any other objects.
---
evil-common.el | 5 ++++-
evil-tests.el | 11 ++++++++++-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/evil-common.el b/evil-common.el
index 5adcdd9036..5a5a1dc734 100644
--- a/evil-common.el
+++ b/evil-common.el
@@ -3207,7 +3207,10 @@ linewise, otherwise it is character wise."
(setq wsend
(evil-with-restriction
;; restrict to current line if we do non-line selection
- (and (not line) (line-beginning-position))
+ (and (not line)
+ (if (member thing '(evil-word evil-WORD))
+ (progn (back-to-indentation) (point))
+ (line-beginning-position)))
(and (not line) (line-end-position))
(evil-bounds-of-not-thing-at-point thing (- dir))))
(when wsend (setq other wsend addcurrent t)))))))
diff --git a/evil-tests.el b/evil-tests.el
index 27dd84e5eb..0460d62989 100644
--- a/evil-tests.el
+++ b/evil-tests.el
@@ -5986,7 +5986,16 @@ Line 2"))
(evil-test-buffer
"foo\n [ ] bar"
("daW")
- "foo\n[]")))
+ "foo\n[]"))
+ (ert-info ("Deleting the only word on a line doesn't delete indentation")
+ (evil-test-buffer
+ " [b]ar"
+ ("daw")
+ " [ ]")
+ (evil-test-buffer
+ " [b]ar"
+ ("daW")
+ " [ ]")))
(ert-deftest evil-test-word-objects-cjk ()
"Test `evil-inner-word' and `evil-a-word' on CJK words"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] elpa/evil 5826a88777: Fix daw deleting indentation when deleting the only word in a line,
ELPA Syncer <=