[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/consult f628806a7f 1/3: consult--multi-lookup: Handled
From: |
ELPA Syncer |
Subject: |
[elpa] externals/consult f628806a7f 1/3: consult--multi-lookup: Handled non-existing tofu'ed candidates |
Date: |
Mon, 18 Apr 2022 18:57:22 -0400 (EDT) |
branch: externals/consult
commit f628806a7fe6fe509b1c4b808aa740d01dd6a895
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
consult--multi-lookup: Handled non-existing tofu'ed candidates
This is necessary to fix https://github.com/oantolin/embark/issues/490.
---
consult.el | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/consult.el b/consult.el
index f8b8878469..c27ded8f3e 100644
--- a/consult.el
+++ b/consult.el
@@ -2065,13 +2065,16 @@ PREVIEW-KEY are the preview keys."
map))
old-map))))
+(defsubst consult--tofu-p (char)
+ "Return non-nil if CHAR is a tofu."
+ (<= consult--tofu-char char (+ consult--tofu-char consult--tofu-range -1)))
+
(defun consult--fry-the-tofus (&rest _)
"Fry the tofus in the minibuffer."
(let* ((min (minibuffer-prompt-end))
(max (point-max))
- (pos max)
- (high (+ consult--tofu-char consult--tofu-range -1)))
- (while (and (> pos min) (<= consult--tofu-char (char-before pos) high))
+ (pos max))
+ (while (and (> pos min) (consult--tofu-p (char-before pos)))
(setq pos (1- pos)))
(when (< pos max)
(add-text-properties pos max '(invisible t rear-nonsticky t
cursor-intangible t)))))
@@ -2277,10 +2280,12 @@ INHERIT-INPUT-METHOD, if non-nil the minibuffer
inherits the input method."
(defun consult--multi-lookup (sources _ candidates cand)
"Lookup CAND in CANDIDATES given SOURCES."
- (if-let (found (member cand candidates))
- (cons (cdr (get-text-property 0 'multi-category (car found)))
- (consult--multi-source sources cand))
- (unless (string-blank-p cand)
+ (unless (string-blank-p cand)
+ (if (consult--tofu-p (aref cand (1- (length cand))))
+ (cons (if-let (found (member cand candidates))
+ (cdr (get-text-property 0 'multi-category (car found)))
+ (substring cand 0 -1))
+ (consult--multi-source sources cand))
(list cand))))
(defun consult--multi-candidates (sources)
@@ -2977,10 +2982,9 @@ CAND is the currently selected candidate."
(eq consult-line-point-placement 'line-beginning))
pos
(let ((beg 0)
- (end (length cand))
- (high (+ consult--tofu-char consult--tofu-range -1)))
+ (end (length cand)))
;; Ignore tofu-encoded unique line number suffix
- (while (and (> end 0) (<= consult--tofu-char (aref cand (1- end))
high))
+ (while (and (> end 0) (consult--tofu-p (aref cand (1- end))))
(setq end (1- end)))
;; Find match end position, remove characters from line end until
;; matching fails