]> code.delx.au - gnu-emacs-elpa/commitdiff
Preselect perfect matches with a leading ^
authorOleh Krehel <ohwoeowho@gmail.com>
Mon, 3 Aug 2015 12:26:03 +0000 (14:26 +0200)
committerOleh Krehel <ohwoeowho@gmail.com>
Mon, 3 Aug 2015 12:26:03 +0000 (14:26 +0200)
* ivy.el (ivy--filter): When e.g. "filter" is in the collection,
  "^filter" input should always select it, even if other candidates
  match.

ivy.el

diff --git a/ivy.el b/ivy.el
index faa469bd97ccecc190111d55b8476058014d226f..21197c3e397a54422ecf8315365ff0f459a50469 100644 (file)
--- a/ivy.el
+++ b/ivy.el
@@ -1415,8 +1415,11 @@ CANDIDATES are assumed to be static."
       (unless (and (not (equal re ivy--old-re))
                    (or (setq ivy--index
                              (or
-                              (cl-position re cands
-                                           :test #'equal)
+                              (cl-position (if (and (> (length re) 0)
+                                                    (eq ?^ (aref re 0)))
+                                               (substring re 1)
+                                             re) cands
+                                             :test #'equal)
                               (and ivy--directory
                                    (cl-position
                                     (concat re "/") cands