branch: master commit 607fd1f6bed0dfd5bdfe65ee11f33fa8aac683d2 Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
Bring back the lost perfect match logic * ivy.el (ivy--recompute-index): Don't defer the perfect match logic to `ivy-index-functions-alist'. (ivy-recompute-index-swiper): Simplify. Once again, if the minibuffer text becomes `equal' to one of the candidates, that candidate will be selected. Fixes #270 --- ivy.el | 46 +++++++++++++++++++++++----------------------- 1 files changed, 23 insertions(+), 23 deletions(-) diff --git a/ivy.el b/ivy.el index f985ef7..1cbaaf7 100644 --- a/ivy.el +++ b/ivy.el @@ -1657,13 +1657,24 @@ CANDIDATES are assumed to be static." (cdr (assoc t ivy-index-functions-alist)) #'ivy-recompute-index-zero))) (setq ivy--index - (or (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))) + (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 ""))) @@ -1679,22 +1690,11 @@ CANDIDATES are assumed to be static." (let ((tail (nthcdr ivy--index ivy--old-cands)) idx) (if (and tail ivy--old-cands (not (equal "^" ivy--old-re))) - (or (and (not (equal re-str ivy--old-re)) - (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)))) - (progn - (while (and tail (null idx)) - ;; Compare with eq to handle equal duplicates in cands - (setq idx (cl-position (pop tail) cands))) - (or idx 0))) + (progn + (while (and tail (null idx)) + ;; Compare with eq to handle equal duplicates in cands + (setq idx (cl-position (pop tail) cands))) + (or idx 0)) ivy--index))) (defun ivy-recompute-index-zero (_re-str _cands)