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

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

[elpa] master 07c65b3 325/399: ivy.el (ivy--set-index-dynamic-collection


From: Oleh Krehel
Subject: [elpa] master 07c65b3 325/399: ivy.el (ivy--set-index-dynamic-collection): Extract
Date: Sat, 20 Jul 2019 14:57:49 -0400 (EDT)

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

    ivy.el (ivy--set-index-dynamic-collection): Extract
    
    Re #2112
---
 ivy.el | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/ivy.el b/ivy.el
index 90be1e3..03566ca 100644
--- a/ivy.el
+++ b/ivy.el
@@ -606,6 +606,14 @@ When non-nil, ivy will wait until the first chunk of 
asynchronous
 candidates has been received before selecting the last
 preselected candidate.")
 
+(defun ivy--set-index-dynamic-collection ()
+  (when ivy--trying-to-resume-dynamic-collection
+    (let ((preselect-index
+           (ivy--preselect-index (ivy-state-preselect ivy-last) 
ivy--all-candidates)))
+      (when preselect-index
+        (ivy-set-index preselect-index)))
+    (setq ivy--trying-to-resume-dynamic-collection nil)))
+
 (defcustom ivy-case-fold-search-default
   (if search-upper-case
       'auto
@@ -2189,12 +2197,11 @@ This is useful for recursive `ivy-read'."
         ;; Needed for anchor to work
         (setq ivy--old-cands coll)
         (setq ivy--old-cands (ivy--filter initial-input coll)))
-      (setq ivy--trying-to-resume-dynamic-collection
-            (and preselect dynamic-collection))
-      (when (and (integerp preselect)
-                 (not ivy--trying-to-resume-dynamic-collection))
-        (setq ivy--old-re "")
-        (ivy-set-index preselect))
+      (unless (setq ivy--trying-to-resume-dynamic-collection
+                    (and preselect dynamic-collection))
+        (when (integerp preselect)
+          (setq ivy--old-re "")
+          (ivy-set-index preselect)))
       (setq ivy--all-candidates coll)
       (unless (integerp preselect)
         (ivy-set-index (or
@@ -3003,11 +3010,7 @@ Should be run via minibuffer `post-command-hook'."
               (setq ivy--old-text ivy-text)))
           (when (or ivy--all-candidates
                     (not (get-process " *counsel*")))
-            (when ivy--trying-to-resume-dynamic-collection
-              (when-let* ((preselect (ivy-state-preselect ivy-last))
-                          (preselect-index (ivy--preselect-index preselect 
ivy--all-candidates)))
-                (ivy-set-index preselect-index))
-              (setq ivy--trying-to-resume-dynamic-collection nil))
+            (ivy--set-index-dynamic-collection)
             (ivy--insert-minibuffer
              (ivy--format ivy--all-candidates))))
       (cond (ivy--directory



reply via email to

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