avy.el (avy--find-visible-regions): Add bounds safety

Re abo-abo/lispy#139
This commit is contained in:
Oleh Krehel 2015-11-14 11:17:53 +01:00
parent edf1259f25
commit f341c2f18f

5
avy.el
View File

@ -567,6 +567,9 @@ Use OVERLAY-FN to visualize the decision overlay."
(defun avy--find-visible-regions (rbeg rend)
"Return a list of all visible regions between RBEG and REND."
(setq rbeg (max rbeg (point-min)))
(setq rend (min rend (point-max)))
(when (< rbeg rend)
(let (visibles beg)
(save-excursion
(save-restriction
@ -576,7 +579,7 @@ Use OVERLAY-FN to visualize the decision overlay."
(goto-char (avy--next-invisible-point))
(push (cons beg (point)) visibles)
(setq beg (goto-char (avy--next-visible-point))))
(nreverse visibles)))))
(nreverse visibles))))))
(defun avy--regex-candidates (regex &optional beg end pred group)
"Return all elements that match REGEX.