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

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

[elpa] master 08dd58b 003/399: ivy.el (ivy--regex-fuzzy): Don't allow ne


From: Oleh Krehel
Subject: [elpa] master 08dd58b 003/399: ivy.el (ivy--regex-fuzzy): Don't allow newlines in wildcards
Date: Sat, 20 Jul 2019 14:56:36 -0400 (EDT)

branch: master
commit 08dd58b2c6204697cf792419c0ef4ea7ca9fbc41
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    ivy.el (ivy--regex-fuzzy): Don't allow newlines in wildcards
    
    ag (the Silver Searcher) suffers from this:
    
        ag --nocolor --nogroup  \(b\)[^a]*\(a\)[^c]*\(c\)[^k]*\(k\)
    
    This will produce way too many matches, because e.g. ag thinks [^a]
    should also match newlines, which means that we can get "b" on one
    line, "a" on the second and so on.
    
    * ivy-test.el (ivy--regex-fuzzy): Update test.
    
    Fixes #1907
---
 ivy-test.el | 8 ++++----
 ivy.el      | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/ivy-test.el b/ivy-test.el
index 7fc34be..12c1077 100644
--- a/ivy-test.el
+++ b/ivy-test.el
@@ -253,13 +253,13 @@ will bring the behavior in line with the newer Emacsen."
 
 (ert-deftest ivy--regex-fuzzy ()
   (should (string= (ivy--regex-fuzzy "tmux")
-                   "\\(t\\)[^m]*\\(m\\)[^u]*\\(u\\)[^x]*\\(x\\)"))
+                   "\\(t\\)[^m\n]*\\(m\\)[^u\n]*\\(u\\)[^x\n]*\\(x\\)"))
   (should (string= (ivy--regex-fuzzy ".tmux")
-                   
"\\(\\.\\)[^t]*\\(t\\)[^m]*\\(m\\)[^u]*\\(u\\)[^x]*\\(x\\)"))
+                   
"\\(\\.\\)[^t\n]*\\(t\\)[^m\n]*\\(m\\)[^u\n]*\\(u\\)[^x\n]*\\(x\\)"))
   (should (string= (ivy--regex-fuzzy "^tmux")
-                   "^\\(t\\)[^m]*\\(m\\)[^u]*\\(u\\)[^x]*\\(x\\)"))
+                   "^\\(t\\)[^m\n]*\\(m\\)[^u\n]*\\(u\\)[^x\n]*\\(x\\)"))
   (should (string= (ivy--regex-fuzzy "^tmux$")
-                   "^\\(t\\)[^m]*\\(m\\)[^u]*\\(u\\)[^x]*\\(x\\)$"))
+                   "^\\(t\\)[^m\n]*\\(m\\)[^u\n]*\\(u\\)[^x\n]*\\(x\\)$"))
   (should (string= (ivy--regex-fuzzy "")
                    ""))
   (should (string= (ivy--regex-fuzzy "^")
diff --git a/ivy.el b/ivy.el
index 7d833a6..669a803 100644
--- a/ivy.el
+++ b/ivy.el
@@ -2558,7 +2558,7 @@ Insert .* between each char."
                     (apply #'concat
                            (cl-mapcar
                             #'concat
-                            (cons "" (cdr (mapcar (lambda (c) (format "[^%c]*" 
c))
+                            (cons "" (cdr (mapcar (lambda (c) (format 
"[^%c\n]*" c))
                                                   lst)))
                             (mapcar (lambda (x) (format "\\(%s\\)" 
(regexp-quote (char-to-string x))))
                                     lst))))



reply via email to

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