branch: externals/consult commit 5563dfc6a182da22885e1d1e138df3d9280c8c46 Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
consult-info: Prevent search from getting stuck for input `#.*#` --- consult-info.el | 7 ++++--- consult.el | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/consult-info.el b/consult-info.el index d08a018d7f..50f976ea92 100644 --- a/consult-info.el +++ b/consult-info.el @@ -40,11 +40,11 @@ (widen) (goto-char (point-min)) ;; TODO subfile support?! - (while (ignore-errors (re-search-forward (car regexps) nil t)) + (while (and (not (eobp)) + (ignore-errors (re-search-forward (car regexps) nil t))) (let ((bol (pos-bol)) (eol (pos-eol)) node cand) - (goto-char eol) (when (save-excursion (goto-char bol) (and @@ -78,7 +78,8 @@ (setq cand (funcall hl (buffer-substring-no-properties bol eol))) (put-text-property 0 (length cand) 'consult--info (list (format "(%s)%s" manual node) bol buffer) cand) - (push cand candidates)))))) + (push cand candidates)) + (goto-char (1+ eol)))))) (nreverse candidates))) (defun consult-info--position (cand) diff --git a/consult.el b/consult.el index a70569ee64..550e7d07e0 100644 --- a/consult.el +++ b/consult.el @@ -662,8 +662,10 @@ If no capturing groups are used highlight the whole match. Case is ignored if IGNORE-CASE is non-nil." (dolist (re regexps) (let ((i 0)) - (while (let ((case-fold-search ignore-case)) - (string-match re str i)) + (while (and (let ((case-fold-search ignore-case)) + (string-match re str i)) + ;; Ensure that regexp search made progress (edge case for .*) + (> (match-end 0) i)) ;; Unfortunately there is no way to avoid the allocation of the match ;; data, since the number of capturing groups is unknown. (let ((m (match-data)))