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

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

[elpa] externals/ivy-hydra 496a5e2 105/395: counsel.el: Fix ivy-occur iv


From: Basil L. Contovounesios
Subject: [elpa] externals/ivy-hydra 496a5e2 105/395: counsel.el: Fix ivy-occur ivy--regex-function bug
Date: Thu, 25 Feb 2021 08:31:41 -0500 (EST)

branch: externals/ivy-hydra
commit 496a5e298add93690711fdc0b113126ae3f9f221
Author: Oleh Krehel <ohwoeowho@gmail.com>
Commit: Oleh Krehel <ohwoeowho@gmail.com>

    counsel.el: Fix ivy-occur ivy--regex-function bug
    
    When `ivy--regex-function' is overwritten by e.g. `swiper',
    `ivy-occur-revert-buffer' fails. Fix this by saving this data in
    `ivy-last'.
---
 counsel.el  |  2 +-
 ivy-test.el | 11 ++++++-----
 ivy.el      | 13 +++++++------
 3 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/counsel.el b/counsel.el
index b0c7dbe..1dd867c 100644
--- a/counsel.el
+++ b/counsel.el
@@ -2835,7 +2835,7 @@ NEEDLE is the search string."
 (defun counsel--grep-regex (str)
   (counsel--elisp-to-pcre
    (setq ivy--old-re
-         (funcall ivy--regex-function str))
+         (funcall (ivy-state-re-builder ivy-last) str))
    counsel--regex-look-around))
 
 (defun counsel--ag-extra-switches (regex)
diff --git a/ivy-test.el b/ivy-test.el
index fb6d849..2e9e25b 100644
--- a/ivy-test.el
+++ b/ivy-test.el
@@ -44,6 +44,8 @@
 
 (message "%s" (emacs-version))
 
+(setq ivy-last (make-ivy-state))
+
 (ert-deftest ivy--lazy-load-ffap--ffap-url-p ()
   (should (not (memq 'ffap require-features)))
   (should (not (fboundp 'ffap-url-p)))
@@ -401,7 +403,6 @@ will bring the behavior in line with the newer Emacsen."
                      90 96 (face ivy-current-match read-only nil)))))
 
 (ert-deftest ivy--filter ()
-  (setq ivy-last (make-ivy-state))
   (should (equal (ivy--filter "the" '("foo" "the" "The"))
                  '("the" "The")))
   (should (equal (ivy--filter "The" '("foo" "the" "The"))
@@ -1128,14 +1129,14 @@ a buffer visiting a file."
   ;; negative lookahead: lines with "ivy", without "-"
   (should
    (string=
-    (let ((counsel--regex-look-around t)
-          (ivy--regex-function 'ivy--regex-plus))
+    (cl-letf ((counsel--regex-look-around t)
+              ((ivy-state-re-builder ivy-last) #'ivy--regex-plus))
       (counsel--grep-regex "ivy ! -"))
     "^(?=.*ivy)(?!.*-)"))
   (should
    (string=
-    (let ((counsel--regex-look-around t)
-          (ivy--regex-function 'ivy--regex-fuzzy))
+    (cl-letf ((counsel--regex-look-around t)
+              ((ivy-state-re-builder ivy-last) #'ivy--regex-fuzzy))
       (counsel--grep-regex "ivy"))
     "(i)[^v\n]*(v)[^y\n]*(y)")))
 
diff --git a/ivy.el b/ivy.el
index f0f02cb..9008c1c 100644
--- a/ivy.el
+++ b/ivy.el
@@ -2225,12 +2225,13 @@ This is useful for recursive `ivy-read'."
     (setq ivy--extra-candidates (ivy--compute-extra-candidates caller))
     (setq ivy--directory nil)
     (setq ivy-case-fold-search ivy-case-fold-search-default)
-    (setq ivy--regex-function
-          (or re-builder
-              (and (functionp collection)
-                   (cdr (assq collection ivy-re-builders-alist)))
-              (ivy-alist-setting ivy-re-builders-alist)
-              #'ivy--regex))
+    (setf (ivy-state-re-builder ivy-last)
+          (setq ivy--regex-function
+                (or re-builder
+                    (and (functionp collection)
+                         (cdr (assq collection ivy-re-builders-alist)))
+                    (ivy-alist-setting ivy-re-builders-alist)
+                    #'ivy--regex)))
     (setq ivy--subexps 0)
     (setq ivy--regexp-quote #'regexp-quote)
     (setq ivy--old-text "")



reply via email to

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