branch: elpa/evil commit 1d63e750bc8f37aa1b8f0eabe86b598973ab75b1 Author: Tom Dalziel <tom...@hotmail.com> Commit: Tom Dalziel <33435574+tomd...@users.noreply.github.com>
Revert point if 0 replacements made in ex substitution --- evil-commands.el | 4 +++- evil-tests.el | 11 ++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/evil-commands.el b/evil-commands.el index b0a4fa1158..4e6109abef 100644 --- a/evil-commands.el +++ b/evil-commands.el @@ -3979,7 +3979,9 @@ reveal.el. OPEN-SPOTS is a local version of `reveal-open-spots'." (if count-only "Found" "Replaced") evil-ex-substitute-nreplaced (if (/= evil-ex-substitute-nreplaced 1) "s" "")) - (evil-first-non-blank))) + (if (and (= 0 evil-ex-substitute-nreplaced) evil-ex-point) + (goto-char evil-ex-point) + (evil-first-non-blank)))) (evil-define-operator evil-ex-repeat-substitute (beg end flags) diff --git a/evil-tests.el b/evil-tests.el index 457c5b52ef..f9bc6ec2ec 100644 --- a/evil-tests.el +++ b/evil-tests.el @@ -7733,12 +7733,17 @@ golf h[o]>tel"))) (ert-info ("Substitute doesn't match final empty line") (evil-test-buffer "abc\n[d]ef\n\nghi" - (":s/$/4") + (":s/$/4" [return]) "abc\n[d]ef4\n\nghi") (evil-test-buffer "abc\n[d]ef\n\nghi" - (":s/f\\w*/4") - "abc\n[d]e4\n\nghi"))) + (":s/f\\w*/4" [return]) + "abc\n[d]e4\n\nghi")) + (ert-info ("Substitute doesn't move point if 0 matches") + (evil-test-buffer + "abc\nd[e]f\nghi" + (":%s/nothere/foo" [return]) + "abc\nd[e]f\nghi"))) (ert-deftest evil-test-ex-repeat-substitute-replacement () "Test `evil-ex-substitute' with repeating of previous substitutions."