]> code.delx.au - gnu-emacs-elpa/commitdiff
Fix the preselect for (swiper "one") again
authorOleh Krehel <ohwoeowho@gmail.com>
Sun, 29 Nov 2015 10:13:45 +0000 (11:13 +0100)
committerOleh Krehel <ohwoeowho@gmail.com>
Sun, 29 Nov 2015 10:13:45 +0000 (11:13 +0100)
* ivy.el (ivy--reset-state): Take into account :preselect being integer.
This means that it's void once the candidates are filtered over
:initial-input.

Fixes #292

ivy.el

diff --git a/ivy.el b/ivy.el
index e89fbd330e457aeb94c894f3787b375b35819645..a5656296180f44fc158bfe8fa263c313c271e377 100644 (file)
--- a/ivy.el
+++ b/ivy.el
@@ -1199,21 +1199,25 @@ This is useful for recursive `ivy-read'."
           (setq coll (cons preselect coll))))
       (setq ivy--old-re nil)
       (setq ivy--old-cands nil)
+      (when (integerp preselect)
+        (setq ivy--old-re "")
+        (setq ivy--index preselect))
       (when initial-input
         ;; Needed for anchor to work
         (setq ivy--old-cands coll)
         (setq ivy--old-cands (ivy--filter initial-input coll)))
       (setq ivy--all-candidates coll)
-      (setq ivy--index (or
-                        (and dynamic-collection
-                             ivy--index)
-                        (and preselect
-                             (ivy--preselect-index
-                              preselect
-                              (if initial-input
-                                  ivy--old-cands
-                                coll)))
-                        0)))
+      (unless (integerp preselect)
+        (setq ivy--index (or
+                          (and dynamic-collection
+                               ivy--index)
+                          (and preselect
+                               (ivy--preselect-index
+                                preselect
+                                (if initial-input
+                                    ivy--old-cands
+                                  coll)))
+                          0))))
     (setq ivy-exit nil)
     (setq ivy--default (or
                         (thing-at-point 'url)