branch: master
commit f6f3963f52ac94f6388deb57fef6659612b6deba
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>
Bind case-fold-search to t when the input is all lower-case
* ivy.el (ivy--filter): Update.
* ivy-test.el (ivy--filter): Add test.
- input "the" matches both "the" and "The".
- input "The" matches only "The".
Fixes #166
---
ivy-test.el | 8 ++++++++
ivy.el | 1 +
2 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/ivy-test.el b/ivy-test.el
index af0fc60..10dd8f9 100644
--- a/ivy-test.el
+++ b/ivy-test.el
@@ -114,3 +114,11 @@
#("\nDESCRIPTION\nFUNCTION
LETTERS\nSWITCHES\nDIAGNOSTICS\nEXAMPLE 1\nEXAMPLE 2\nEXAMPLE 3\nSEE
ALSO\nAUTHOR"
0 90 (read-only nil)
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"))
+ '("The"))))
+
diff --git a/ivy.el b/ivy.el
index 45ed244..fc11c3d 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1279,6 +1279,7 @@ Should be run via minibuffer `post-command-hook'."
CANDIDATES are assumed to be static."
(let* ((re (funcall ivy--regex-function name))
(matcher (ivy-state-matcher ivy-last))
+ (case-fold-search (string= name (downcase name)))
(cands (cond
(matcher
(funcall matcher re candidates))