avy.el (avy--process): Fix the candidates list being modified when restarting

For example, with multiple windows, `avy-goto-char' followed by "x"
would change the overlays to a subset of the overlays in the current window.
This commit is contained in:
Oleh Krehel 2018-06-15 17:01:33 +02:00
parent 7cfe11e3c1
commit 7c40f5e381

5
avy.el
View File

@ -756,13 +756,14 @@ Use OVERLAY-FN to visualize the decision overlay."
(setq candidates (setq candidates
(mapcar (lambda (x) (cons x (selected-window))) (mapcar (lambda (x) (cons x (selected-window)))
candidates))) candidates)))
(let ((res (avy--process-1 candidates overlay-fn))) (let ((original-cands (copy-sequence candidates))
(res (avy--process-1 candidates overlay-fn)))
(cond (cond
((null res) ((null res)
(message "zero candidates") (message "zero candidates")
t) t)
((eq res 'restart) ((eq res 'restart)
(avy--process candidates overlay-fn)) (avy--process original-cands overlay-fn))
;; ignore exit from `avy-handler-function' ;; ignore exit from `avy-handler-function'
((eq res 'exit)) ((eq res 'exit))
(t (t