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

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

[elpa] master f29207f 324/399: Add ability to resume dynamic collections


From: Oleh Krehel
Subject: [elpa] master f29207f 324/399: Add ability to resume dynamic collections
Date: Sat, 20 Jul 2019 14:57:49 -0400 (EDT)

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

    Add ability to resume dynamic collections
    
    If `dynamic-collection' is set, Ivy will wait until the first chunk of
    candidates has been received before selecting the preselected
    candidate.
    
    Fixes #1095
    Fixes #2112
---
 ivy.el | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/ivy.el b/ivy.el
index a7f1a66..90be1e3 100644
--- a/ivy.el
+++ b/ivy.el
@@ -600,6 +600,12 @@ Either a string or a list for `ivy-re-match'.")
 (defvar ivy--old-text ""
   "Store old `ivy-text' for dynamic completion.")
 
+(defvar ivy--trying-to-resume-dynamic-collection nil
+  "Non-nil if resuming from a dynamic collection.
+When non-nil, ivy will wait until the first chunk of asynchronous
+candidates has been received before selecting the last
+preselected candidate.")
+
 (defcustom ivy-case-fold-search-default
   (if search-upper-case
       'auto
@@ -2179,13 +2185,16 @@ This is useful for recursive `ivy-read'."
       (setq coll (ivy--set-candidates coll))
       (setq ivy--old-re nil)
       (setq ivy--old-cands nil)
-      (when (integerp preselect)
-        (setq ivy--old-re "")
-        (ivy-set-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--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))
       (setq ivy--all-candidates coll)
       (unless (integerp preselect)
         (ivy-set-index (or
@@ -2994,6 +3003,11 @@ 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--insert-minibuffer
              (ivy--format ivy--all-candidates))))
       (cond (ivy--directory



reply via email to

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