Skip to content

Commit

Permalink
Partially revert recent ivy--re-filter refactor
Browse files Browse the repository at this point in the history
The use of ignore-errors informed not just the control flow, but
also the return value of the function, and other parts of the
package apparently rely on ivy--re-filter returning nil on error.

* ivy.el (ivy--re-filter): Return nil on error.

Fixes #3048.
  • Loading branch information
basil-conto committed May 24, 2024
1 parent 8133016 commit 87c53b0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ivy.el
Original file line number Diff line number Diff line change
Expand Up @@ -3614,8 +3614,11 @@ In any Ivy completion session, the case folding starts with
RE is a list of cons cells, with a regexp car and a boolean cdr.
When the cdr is t, the car must match.
Otherwise, the car must not match."
(unless (member re '("" ()))
(if (member re '("" ()))
candidates
(setq candidates (copy-sequence candidates))
;; Return nil (not candidates) on error, e.g., when we try to filter
;; `swiper-isearch' numeric candidates with `string-match-p'.
(ignore-errors
(dolist (re (if (stringp re) (list (cons re t)) re))
(let* ((re-str (car re))
Expand All @@ -3626,8 +3629,8 @@ Otherwise, the car must not match."
(setq candidates
(cl-delete nil candidates
(if (cdr re) :if-not :if)
pred))))))
candidates)
pred))))
candidates)))

(defun ivy--filter (name candidates)
"Return all items that match NAME in CANDIDATES.
Expand Down

0 comments on commit 87c53b0

Please sign in to comment.