diff options
| author | Tom Dalziel <tom_dl@hotmail.com> | 2022-04-20 09:39:12 +0100 |
|---|---|---|
| committer | Tom Dalziel <tom_dl@hotmail.com> | 2022-04-20 09:39:12 +0100 |
| commit | 6fa371222f5d56cf96103aa301da8bcbf6c15cc2 (patch) | |
| tree | 437605622d700f3f14fa0341870732019e6a12ae | |
| parent | 2a5360eccc9bcb784e61c3b58ebe4690f2c7ea49 (diff) | |
Refactor substitution empty last line handling
| -rw-r--r-- | evil-commands.el | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/evil-commands.el b/evil-commands.el index 3344c42..545de06 100644 --- a/evil-commands.el +++ b/evil-commands.el @@ -3826,17 +3826,12 @@ 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 (= match-end end-marker) + (when (and (= match-end end-marker) (not match-contains-newline) (bolp)) ;; The range (beg end) includes the final newline which means - ;; 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))) + ;; end-marker is on one line down. + ;; With the exception of explicitly substituting newlines, + ;; we abort when the match ends here and it's an empty line + (throw 'exit-search t)) (setq evil-ex-substitute-last-point match-beg) (if confirm (let ((prompt |
