Skip to content

Commit

Permalink
ivy.el (ivy--update-minibuffer): allow to resumed using stale data fr…
Browse files Browse the repository at this point in the history
…om dynamic collection
  • Loading branch information
kiennq committed Dec 16, 2020
1 parent 1723799 commit 844aea6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ivy.el
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,10 @@ If the text hasn't changed as a result, forward to `ivy-alt-done'."
(setq ivy-exit 'done)
(exit-minibuffer))

(defcustom ivy-resume-with-stale-data nil
"Allow to use stale results when resuming from dynamic collection."
:type 'boolean)

(defun ivy--restore-session (&optional session)
"Resume a recorded completion SESSION, if any exists."
(when ivy--sessions
Expand All @@ -1203,7 +1207,8 @@ With a prefix arg, try to restore a recorded completion session,
if one exists."
(interactive)
(when (or current-prefix-arg session)
(ivy--restore-session session))
(ivy--restore-session session)
(setq this-command 'ivy-resume))

(if (or (null (ivy-state-action ivy-last))
(eq (ivy--get-action ivy-last) #'identity))
Expand Down Expand Up @@ -3300,7 +3305,10 @@ Should be run via minibuffer `post-command-hook'."
(unless (or (equal ivy--old-text ivy-text)
(eq this-command 'ivy-resume))
(while-no-input
(setq coll (ivy--dynamic-collection-cands ivy-text))
(setq coll (if (and ivy-resume-with-stale-data
ivy--trying-to-resume-dynamic-collection)
ivy--all-candidates
(ivy--dynamic-collection-cands ivy-text)))
(when (eq coll 0)
(setq coll nil)
(setq ivy--old-re nil)
Expand Down

0 comments on commit 844aea6

Please sign in to comment.