]> code.delx.au - gnu-emacs-elpa/commitdiff
Fix broken candidate index in ivy-resume
authorOleh Krehel <ohwoeowho@gmail.com>
Tue, 24 Nov 2015 11:09:37 +0000 (12:09 +0100)
committerOleh Krehel <ohwoeowho@gmail.com>
Tue, 24 Nov 2015 11:09:37 +0000 (12:09 +0100)
* ivy.el (ivy--reset-state): When given initial-input, call
  `ivy--preselect-index' on candidates filtered by initial-input. This
  is important for `ivy-resume'.

ivy.el

diff --git a/ivy.el b/ivy.el
index 050f4602784cbc35f02166c83f93bc20f99de66a..321c42099bf552fed89e7a8deef15acc2515b3e2 100644 (file)
--- a/ivy.el
+++ b/ivy.el
@@ -1194,19 +1194,23 @@ This is useful for recursive `ivy-read'."
                       (cl-find-if (lambda (x) (string-match re x))
                                   coll)))
           (setq coll (cons preselect coll))))
-      (setq ivy--index (or
-                        (and dynamic-collection
-                             ivy--index)
-                        (and preselect
-                             (ivy--preselect-index preselect coll))
-                        0))
       (setq ivy--old-re nil)
       (setq ivy--old-cands nil)
       (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--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)))
     (setq ivy-exit nil)
     (setq ivy--default (or
                         (thing-at-point 'url)