From c67b98af06253deb3e603265890869fca5bf83f4 Mon Sep 17 00:00:00 2001 From: Kien Nguyen Date: Wed, 16 Dec 2020 16:02:46 +0900 Subject: [PATCH] ivy.el (ivy--update-minibuffer): allow to resumed using staled data from dynamic collection --- ivy.el | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ivy.el b/ivy.el index 0167b415..62666544 100644 --- a/ivy.el +++ b/ivy.el @@ -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-staled-data nil + "Allow to use staled 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 @@ -1196,6 +1200,7 @@ If the text hasn't changed as a result, forward to `ivy-alt-done'." (setq ivy--all-candidates (plist-get data :all-candidates)) (setq ivy-text (plist-get data :text))))) + ;;;###autoload (defun ivy-resume (&optional session) "Resume the last completion session, or SESSION if non-nil. @@ -1203,7 +1208,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)) @@ -3300,7 +3306,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-staled-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)