branch: externals/consult commit 073713645867a8b7de7703e91411875e073c9292 Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
consult-line-multi/consult-info: Disallow empty candidates --- consult-info.el | 16 ++++++++-------- consult.el | 12 ++++++------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/consult-info.el b/consult-info.el index 139401cecb..361a150c50 100644 --- a/consult-info.el +++ b/consult-info.el @@ -45,8 +45,9 @@ (eol (pos-eol)) node cand) (when (save-excursion - (goto-char bol) (and + (> eol bol) + (goto-char bol) (>= (- (point) 2) (point-min)) ;; Information separator character (not (eq (char-after (- (point) 2)) ?\^_)) @@ -59,12 +60,11 @@ (re-search-forward r eol t)) (cdr regexps)) ;; Find node beginning - (progn - (goto-char bol) - (if (search-backward "\n\^_" nil 'move) - (forward-line 2) - (when (looking-at "\^_") - (forward-line 1)))) + (goto-char bol) + (if (search-backward "\n\^_" nil 'move) + (forward-line 2) + (when (looking-at "\^_") + (forward-line 1))) ;; Node name (re-search-forward "Node:[ \t]*" nil t) (setq node @@ -74,7 +74,7 @@ (skip-chars-forward "^,\t\n") (point)))))) (setq cand (funcall hl (buffer-substring-no-properties bol eol))) - (put-text-property 0 (length cand) 'consult--info + (put-text-property 0 1 'consult--info (list (format "(%s)%s" manual node) bol buffer) cand) (push cand candidates)) (goto-char (1+ eol)))))) diff --git a/consult.el b/consult.el index 7fe4383675..f545adc249 100644 --- a/consult.el +++ b/consult.el @@ -3165,10 +3165,11 @@ BUFFERS is the list of buffers." (cl-incf line (consult--count-lines (match-beginning 0))) (let ((bol (pos-bol)) (eol (pos-eol))) - (when (seq-every-p (lambda (r) - (goto-char bol) - (re-search-forward r eol t)) - (cdr regexps)) + (when (and (> eol bol) + (seq-every-p (lambda (r) + (goto-char bol) + (re-search-forward r eol t)) + (cdr regexps))) (push (consult--location-candidate (funcall hl (buffer-substring-no-properties bol eol)) (cons buf bol) (1- line)) @@ -4310,8 +4311,7 @@ If NORECORD is non-nil, do not record the buffer switch in the buffer list." (when (and (not (gethash file ht)) (string-prefix-p root file)) (let ((part (substring file len))) (when (equal part "") (setq part "./")) - (put-text-property 0 (length part) - 'multi-category `(file . ,file) part) + (put-text-property 0 1 'multi-category `(file . ,file) part) (push part items)))))))) "Project file candidate source for `consult-buffer'.")