Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions ivy.el
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,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 @@ -1221,7 +1225,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 @@ -2367,7 +2372,9 @@ This is useful for recursive `ivy-read'."
""
(ivy-state-collection ivy-last)
(ivy-state-predicate ivy-last))))
(setq coll (if (and (eq this-command 'ivy-resume) (not (buffer-modified-p)))
(setq coll (if (and (eq this-command 'ivy-resume)
(not (and (eq caller 'swiper-isearch)
(buffer-modified-p))))
ivy--all-candidates
(ivy--dynamic-collection-cands (or initial-input "")))))
((consp (car-safe collection))
Expand Down Expand Up @@ -3399,7 +3406,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