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

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

[elpa] master c59752b 16/19: Update sorting order, make sure that perfec


From: Oleh Krehel
Subject: [elpa] master c59752b 16/19: Update sorting order, make sure that perfect match is selected
Date: Thu, 16 Apr 2015 12:18:14 +0000

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

    Update sorting order, make sure that perfect match is selected
    
    ivy.el (ivy-completions): Update.
    
    When the regex matches perfectly, select it.
---
 ivy.el |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/ivy.el b/ivy.el
index 3ac5931..0bb58fe 100644
--- a/ivy.el
+++ b/ivy.el
@@ -265,6 +265,7 @@ Turning on Ivy mode will set `completing-read-function' to
 `ivy-completing-read'."
   :group 'ivy
   :global t
+  :lighter " ivy"
   (if ivy-mode
       (setq completing-read-function 'ivy-completing-read)
     (setq completing-read-function 'completing-read-default)))
@@ -427,7 +428,6 @@ CANDIDATES is a list of strings."
          (cands (if (and (equal re ivy--old-re)
                          ivy--old-cands)
                     ivy--old-cands
-                  (setq ivy--old-re re)
                   (ignore-errors
                     (cl-remove-if-not
                      (lambda (x) (string-match re x))
@@ -435,12 +435,15 @@ CANDIDATES is a list of strings."
          (tail (nthcdr ivy--index ivy--old-cands))
          (ww (window-width))
          idx)
-    (setq ivy--length (length cands))
     (when (and tail ivy--old-cands)
-      (while (and tail (null idx))
-        ;; Compare with eq to handle equal duplicates in cands
-        (setq idx (cl-position (pop tail) cands)))
-      (setq ivy--index (or idx 0)))
+      (unless (and (not (equal re ivy--old-re))
+                   (setq ivy--index (cl-position re cands :test 'equal)))
+        (while (and tail (null idx))
+          ;; Compare with eq to handle equal duplicates in cands
+          (setq idx (cl-position (pop tail) cands)))
+        (setq ivy--index (or idx 0))))
+    (setq ivy--old-re re)
+    (setq ivy--length (length cands))
     (setq ivy--old-cands cands)
     (when (>= ivy--index ivy--length)
       (setq ivy--index (max (1- ivy--length) 0)))



reply via email to

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