diff --git a/lisp/isearch.el b/lisp/isearch.el index e13a4dda83..0ad97a092f 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -3535,6 +3535,7 @@ isearch-close-unnecessary-overlays (overlay-put ov 'invisible (overlay-get ov 'isearch-invisible)) (overlay-put ov 'isearch-invisible nil))))))) +(defvar isearch-check-overlays nil) (defun isearch-range-invisible (beg end) "Return t if all the text from BEG to END is invisible." @@ -3546,7 +3547,7 @@ isearch-range-invisible (can-be-opened (eq search-invisible 'open)) ;; the list of overlays that could be opened (crt-overlays nil)) - (when (and can-be-opened isearch-hide-immediately) + (when (and can-be-opened isearch-hide-immediately (not isearch-check-overlays)) (isearch-close-unnecessary-overlays beg end)) ;; If the following character is currently invisible, ;; skip all characters with that same `invisible' property value. @@ -3585,9 +3586,10 @@ isearch-range-invisible (if (>= (point) end) (if (and can-be-opened (consp crt-overlays)) (progn - (setq isearch-opened-overlays - (append isearch-opened-overlays crt-overlays)) - (mapc 'isearch-open-overlay-temporary crt-overlays) + (unless isearch-check-overlays + (setq isearch-opened-overlays + (append isearch-opened-overlays crt-overlays)) + (mapc 'isearch-open-overlay-temporary crt-overlays)) nil) (setq isearch-hidden t))))))) @@ -3880,8 +3885,10 @@ isearch-lazy-highlight-search (if (or (not success) (= (point) bound) ; like (bobp) (eobp) in `isearch-search'. (= (match-beginning 0) (match-end 0)) - (funcall isearch-filter-predicate - (match-beginning 0) (match-end 0))) + (let ((search-invisible (and search-invisible 'open)) + (isearch-check-overlays t)) + (funcall isearch-filter-predicate + (match-beginning 0) (match-end 0)))) (setq retry nil))) success) (error nil)))