emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/anzu cb70e6c611 145/288: Fix wrong counting total matched


From: ELPA Syncer
Subject: [nongnu] elpa/anzu cb70e6c611 145/288: Fix wrong counting total matched number when used default input
Date: Thu, 6 Jan 2022 03:58:47 -0500 (EST)

branch: elpa/anzu
commit cb70e6c6111a9b1f6b0f5ff7bf71ce31ab7c9941
Author: Syohei YOSHIDA <syohex@gmail.com>
Commit: Syohei YOSHIDA <syohex@gmail.com>

    Fix wrong counting total matched number when used default input
---
 anzu.el | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/anzu.el b/anzu.el
index e36a089654..2cc7de8768 100644
--- a/anzu.el
+++ b/anzu.el
@@ -131,6 +131,7 @@
 (defvar anzu--cached-count 0)
 (defvar anzu--last-replace-input "")
 (defvar anzu--last-search-state nil)
+(defvar anzu--last-replaced-count nil)
 (defvar anzu--outside-point nil)
 
 (defun anzu--validate-regexp (regexp)
@@ -401,8 +402,11 @@
       (sit-for 2))))
 
 (defun anzu--query-from-string (prompt beg end use-regexp overlay-limit)
-  (let ((from (anzu--read-from-string prompt beg end use-regexp 
overlay-limit)))
-    (if (and (string= from "") query-replace-defaults)
+  (let* ((from (anzu--read-from-string prompt beg end use-regexp 
overlay-limit))
+         (is-empty (string= from "")))
+    (when (and (not is-empty) (not query-replace-defaults))
+      (setq anzu--last-replaced-count anzu--total-matched))
+    (if (and is-empty query-replace-defaults)
         (cons (car query-replace-defaults)
               (query-replace-compile-replacement
                (cdr query-replace-defaults) use-regexp))
@@ -604,7 +608,9 @@
                            (anzu--query-from-at-cursor curbuf beg end 
overlay-limit))
                        (anzu--query-from-string prompt beg end use-regexp 
overlay-limit)))
                (to (if (consp from)
-                       (prog1 (cdr from) (setq from (car from)))
+                       (prog1 (cdr from)
+                         (setq from (car from)
+                               anzu--total-matched anzu--last-replaced-count))
                      (anzu--query-replace-read-to
                       from prompt beg end use-regexp overlay-limit))))
           (anzu--clear-overlays curbuf beg end)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]