[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil b46acf2570: Fix evil-ex-substitute up to EOB
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil b46acf2570: Fix evil-ex-substitute up to EOB |
Date: |
Tue, 4 Oct 2022 06:58:24 -0400 (EDT) |
branch: elpa/evil
commit b46acf25705561a9e065b00581a247efc7a340b2
Author: Axel Forsman <axelsfor@gmail.com>
Commit: Tom Dalziel <33435574+tomdl89@users.noreply.github.com>
Fix evil-ex-substitute up to EOB
Fixes #1682
---
evil-commands.el | 31 +++++++++++++------------------
evil-search.el | 7 ++++---
evil-tests.el | 7 ++++++-
3 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/evil-commands.el b/evil-commands.el
index 0788e8de1b..b704ba7382 100644
--- a/evil-commands.el
+++ b/evil-commands.el
@@ -3854,9 +3854,8 @@ reveal.el. OPEN-SPOTS is a local version of
`reveal-open-spots'."
(orig-point-marker (move-marker (make-marker) (point)))
(end-marker (move-marker (make-marker) end))
(use-reveal confirm)
+ (match-end (make-marker))
reveal-open-spots
- zero-length-match
- match-contains-newline
transient-mark-mode)
(setq evil-ex-substitute-pattern pattern
evil-ex-substitute-replacement replacement
@@ -3871,28 +3870,24 @@ reveal.el. OPEN-SPOTS is a local version of
`reveal-open-spots'."
(goto-char beg)
(catch 'exit-search
(while (re-search-forward evil-ex-substitute-regex end-marker t)
- (when (not (and query-replace-skip-read-only
- (text-property-any (match-beginning 0)
(match-end 0) 'read-only t)))
- (let ((match-str (match-string 0))
- (match-beg (move-marker (make-marker) (match-beginning
0)))
- (match-end (move-marker (make-marker) (match-end 0)))
- (match-data (match-data)))
+ (unless (and query-replace-skip-read-only
+ (text-property-any (match-beginning 0) (match-end
0) 'read-only t))
+ (let ((inhibit-field-text-motion t)
+ (match-beg (match-beginning 0))
+ (match-data (match-data))
+ match-contains-newline zero-length-match)
+ (move-marker match-end (match-end 0))
(goto-char match-beg)
- (setq match-contains-newline
- (string-match-p "\n" (buffer-substring-no-properties
- match-beg match-end)))
- (setq zero-length-match (= match-beg match-end))
- (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.
- ;; With the exception of explicitly substituting newlines,
- ;; we abort when the match ends here and it's an empty line
+ (setq match-contains-newline (< (line-end-position)
match-end)
+ zero-length-match (= match-beg match-end))
+ (when (and (= match-beg end-marker) (> end-marker beg)
(bolp))
+ ;; This line is not included due to range being exclusive
(throw 'exit-search t))
(setq evil-ex-substitute-last-point match-beg)
(if confirm
(let ((prompt
(format "Replace %s with %s (y/n/a/q/l/^E/^Y)? "
- match-str
+ (match-string 0)
(evil-match-substitute-replacement
evil-ex-substitute-replacement
(not case-replace))))
diff --git a/evil-search.el b/evil-search.el
index ae8f2a4dfb..4b14731581 100644
--- a/evil-search.el
+++ b/evil-search.el
@@ -661,9 +661,10 @@ The following properties are supported:
(while (and (not (eobp))
(evil-ex-search-find-next-pattern pattern)
(<= (match-end 0) end)
- (not (and (= (match-end 0) end)
- (string= (evil-ex-pattern-regex
pattern)
- "^"))))
+ (not (and (= (match-beginning 0) end)
+ (save-excursion
+ (goto-char (match-beginning 0))
+ (bolp)))))
(let ((ov (or (pop old-ovs) (make-overlay 0 0))))
(move-overlay ov (match-beginning 0) (match-end 0))
(overlay-put ov 'face face)
diff --git a/evil-tests.el b/evil-tests.el
index 1b61aff868..a9b3a7963a 100644
--- a/evil-tests.el
+++ b/evil-tests.el
@@ -7773,7 +7773,12 @@ golf h[o]>tel")))
(evil-test-buffer
"abc\nd[e]f\nghi"
(":%s/nothere/foo" [return])
- "abc\nd[e]f\nghi")))
+ "abc\nd[e]f\nghi"))
+ (ert-info ("Substitute up to EOB works")
+ (evil-test-buffer
+ "[f]oo"
+ (":s/foo")
+ "")))
(ert-deftest evil-test-ex-repeat-substitute-replacement ()
"Test `evil-ex-substitute' with repeating of previous substitutions."
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] elpa/evil b46acf2570: Fix evil-ex-substitute up to EOB,
ELPA Syncer <=