diff options
| author | Frank Fischer <frank.fischer@mathematik.tu-chemnitz.de> | 2013-05-23 20:17:41 +0200 |
|---|---|---|
| committer | Frank Fischer <frank.fischer@mathematik.tu-chemnitz.de> | 2013-05-23 20:17:41 +0200 |
| commit | 3f1e0217149a9e9a655967f465154eb2560d7b06 (patch) | |
| tree | 5e37d091c54555d130420f6207f2fdd1bd9c7ba8 | |
| parent | 6c42b27dcc9da721b13fbe817e09a477f151af28 (diff) | |
Ensure `evil-delete-backward-word` only deletes newline at bol
If point is not at the beginning of the line, the this function should
only delete characters on the current line, even if they are only
whitespaces. This corresponds to Vim's default behaviour.
| -rw-r--r-- | evil-commands.el | 8 | ||||
| -rw-r--r-- | evil-tests.el | 14 |
2 files changed, 19 insertions, 3 deletions
diff --git a/evil-commands.el b/evil-commands.el index 36c6473..79e0a99 100644 --- a/evil-commands.el +++ b/evil-commands.el @@ -1194,9 +1194,11 @@ Save in REGISTER or in the kill-ring with YANK-HANDLER." "Delete previous word." (if (and (bolp) (not (bobp))) (delete-char -1) - (evil-delete (save-excursion - (evil-backward-word-begin) - (point)) + (evil-delete (max + (save-excursion + (evil-backward-word-begin) + (point)) + (line-beginning-position)) (point) 'exclusive nil))) diff --git a/evil-tests.el b/evil-tests.el index 111f270..1aeafe3 100644 --- a/evil-tests.el +++ b/evil-tests.el @@ -2065,6 +2065,20 @@ ine3 line3 line3 l\n"))) ("zm2j3dd") "line1\n\n[\n]last line\n"))) +(ert-deftest evil-test-delete-backward-word () + "Test `evil-delete-backward-word' in insert state." + :tags '(evil) + (evil-test-buffer + "abc def\n ghi j[k]l\n" + ("i" (kbd "C-w")) + "abc def\n ghi [k]l\n" + ((kbd "C-w")) + "abc def\n [k]l\n" + ((kbd "C-w")) + "abc def\n[k]l\n" + ((kbd "C-w")) + "abc def[k]l\n")) + (ert-deftest evil-test-change () "Test `evil-change'" :tags '(evil operator) |
