branch: master commit f9ef307eea5d1e7fe2cf0fb1503e9bc3e4cac0d4 Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
Improve the preselect index in ivy-resume * ivy.el (ivy--recompute-index): Don't change the ivy--index that was set in `ivy--reset-state' by `ivy-resume'. With this, it's possible to e.g. "<f1> f", enter "for", navigate to "format" and press "C-g". Calling `ivy-resume' will point to "format" still. --- ivy.el | 39 ++++++++++++++++++++------------------- 1 files changed, 20 insertions(+), 19 deletions(-) diff --git a/ivy.el b/ivy.el index 3ae9abc..162cd2e 100644 --- a/ivy.el +++ b/ivy.el @@ -1662,25 +1662,26 @@ CANDIDATES are assumed to be static." (func (or (and caller (cdr (assoc caller ivy-index-functions-alist))) (cdr (assoc t ivy-index-functions-alist)) #'ivy-recompute-index-zero))) - (setq ivy--index - (or - (cl-position (if (and (> (length re-str) 0) - (eq ?^ (aref re-str 0))) - (substring re-str 1) - re-str) cands - :test #'equal) - (and ivy--directory - (cl-position - (concat re-str "/") cands - :test #'equal)) - (and (not (string= name "")) - (not (and (require 'flx nil 'noerror) - (eq ivy--regex-function 'ivy--regex-fuzzy) - (< (length cands) 200))) - - (cl-position (nth ivy--index ivy--old-cands) - cands)) - (funcall func re-str cands))) + (unless (eq this-command 'ivy-resume) + (setq ivy--index + (or + (cl-position (if (and (> (length re-str) 0) + (eq ?^ (aref re-str 0))) + (substring re-str 1) + re-str) cands + :test #'equal) + (and ivy--directory + (cl-position + (concat re-str "/") cands + :test #'equal)) + (and (not (string= name "")) + (not (and (require 'flx nil 'noerror) + (eq ivy--regex-function 'ivy--regex-fuzzy) + (< (length cands) 200))) + + (cl-position (nth ivy--index ivy--old-cands) + cands)) + (funcall func re-str cands)))) (when (and (or (string= name "") (string= name "^")) (not (equal ivy--old-re "")))