* ivy.el (ivy--recompute-index): If the old match is still located in
the current matches after the change in input, keep it selected.
* ivy-test.el (ivy-read): Add test.
Fixes #258
(ivy-with '(let ((ivy-re-builders-alist '((t . ivy--regex-fuzzy))))
(ivy-read "pattern: " '("package-list-packages" "something-else")))
"plp C-m")
- "package-list-packages")))
+ "package-list-packages"))
+ (should (equal
+ (ivy-with '(ivy-read "test" '("aaab" "aaac"))
+ "a C-n <tab> C-m")
+ "aaac")))
(ert-deftest swiper--re-builder ()
(setq swiper--width 4)
(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 (funcall func re-str cands))
+ (setq ivy--index
+ (or (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 "")))