]> code.delx.au - gnu-emacs-elpa/commitdiff
Fix up the "foo ! bar" matching and highlighting
authorOleh Krehel <ohwoeowho@gmail.com>
Tue, 8 Sep 2015 11:48:29 +0000 (13:48 +0200)
committerOleh Krehel <ohwoeowho@gmail.com>
Tue, 8 Sep 2015 11:48:29 +0000 (13:48 +0200)
* ivy.el (ivy--filter): When regex returned is a list, use only the
  first string part.

* swiper.el (swiper--update-input-ivy): When regex returned is a list,
  use only the first string part.

ivy.el
swiper.el

diff --git a/ivy.el b/ivy.el
index 9a76f82364e1d4ed23b9d836442e319a87193e80..5574cd4eb07bcdd2b2b0213623ec53461d57a822 100644 (file)
--- a/ivy.el
+++ b/ivy.el
@@ -1429,6 +1429,7 @@ all of the text contained in the minibuffer."
   "Return all items that match NAME in CANDIDATES.
 CANDIDATES are assumed to be static."
   (let* ((re (funcall ivy--regex-function name))
+         (re-str (if (listp re) (caar re) re))
          (matcher (ivy-state-matcher ivy-last))
          (case-fold-search (string= name (downcase name)))
          (cands (cond
@@ -1469,17 +1470,17 @@ CANDIDATES are assumed to be static."
          (tail (nthcdr ivy--index ivy--old-cands))
          idx)
     (when (and tail ivy--old-cands (not (equal "^" ivy--old-re)))
-      (unless (and (not (equal re ivy--old-re))
+      (unless (and (not (equal re-str ivy--old-re))
                    (or (setq ivy--index
                              (or
-                              (cl-position (if (and (> (length re) 0)
-                                                    (eq ?^ (aref re 0)))
-                                               (substring re 1)
-                                             re) cands
+                              (cl-position (if (and (> (length re-str) 0)
+                                                    (eq ?^ (aref re-str 0)))
+                                               (substring re-str 1)
+                                             re-str) cands
                                              :test #'equal)
                               (and ivy--directory
                                    (cl-position
-                                    (concat re "/") cands
+                                    (concat re-str "/") cands
                                     :test #'equal))))))
         (while (and tail (null idx))
           ;; Compare with eq to handle equal duplicates in cands
@@ -1490,7 +1491,7 @@ CANDIDATES are assumed to be static."
             (or (cl-position (ivy-state-preselect ivy-last)
                              cands :test #'equal)
                 ivy--index)))
-    (setq ivy--old-re (if cands re ""))
+    (setq ivy--old-re (if cands re-str ""))
     (setq ivy--old-cands cands)))
 
 (defvar ivy-format-function 'ivy-format-function-default
index 7535253bdd1e366d3450eeb46f543c0b8c740819..ac1b0ccce05283a5a5fab98b29ee5b65420dc091 100644 (file)
--- a/swiper.el
+++ b/swiper.el
@@ -309,7 +309,8 @@ Please remove it and update the \"swiper\" package."))
   "Called when `ivy' input is updated."
   (with-ivy-window
     (swiper--cleanup)
-    (let* ((re (ivy--regex ivy-text))
+    (let* ((re (funcall ivy--regex-function ivy-text))
+           (re (if (stringp re) re (caar re)))
            (str ivy--current)
            (num (if (string-match "^[0-9]+" str)
                     (string-to-number (match-string 0 str))