branch: master commit 08dd58b2c6204697cf792419c0ef4ea7ca9fbc41 Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
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))))