diff options
| author | Tom Dalziel <tom_dl@hotmail.com> | 2022-04-20 00:26:42 +0100 |
|---|---|---|
| committer | Tom Dalziel <33435574+tomdl89@users.noreply.github.com> | 2022-04-20 01:39:08 +0200 |
| commit | 2a5360eccc9bcb784e61c3b58ebe4690f2c7ea49 (patch) | |
| tree | 114f284c1fe8f89427f4215a10d2bae0d142c3ee /evil-commands.el | |
| parent | b904c4f0bf7a3f2037e3f93a6ced8d7fb6243827 (diff) | |
Exclude final empty line from implicit inclusion in substitution
Fixes #1321
Diffstat (limited to 'evil-commands.el')
| -rw-r--r-- | evil-commands.el | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/evil-commands.el b/evil-commands.el index 8a54de7..3344c42 100644 --- a/evil-commands.el +++ b/evil-commands.el @@ -3826,13 +3826,17 @@ reveal.el. OPEN-SPOTS is a local version of `reveal-open-spots'." (string-match-p "\n" (buffer-substring-no-properties match-beg match-end))) (setq zero-length-match (= match-beg match-end)) - (when (and (string= "^" evil-ex-substitute-regex) - (= (point) end-marker)) + (when (= match-end end-marker) ;; The range (beg end) includes the final newline which means - ;; end-marker is on one line down. With the regex "^" the - ;; beginning of this last line will be matched which we don't - ;; want, so we abort here. - (throw 'exit-search t)) + ;; end-marker is on one line down, causing some issues... + (when (and (not match-contains-newline) (bolp)) + ;; With the exception of explicitly substituting newlines, + ;; we abort when the match ends here and it's an empty line + (throw 'exit-search t)) + (when (string= "^" evil-ex-substitute-regex) + ;; With the regex "^" the beginning of this last line + ;; will be matched which we don't want, so we abort here + (throw 'exit-search t))) (setq evil-ex-substitute-last-point match-beg) (if confirm (let ((prompt |
