[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vertico 4198389 5/7: vertico--prompt-selection: Preserv
From: |
Protesilaos Stavrou |
Subject: |
[elpa] externals/vertico 4198389 5/7: vertico--prompt-selection: Preserve existing faces |
Date: |
Sat, 10 Apr 2021 15:17:18 -0400 (EDT) |
branch: externals/vertico
commit 4198389f71d5ef5c42c06f0d830952145f89944f
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
vertico--prompt-selection: Preserve existing faces
* When browsing the history, the candidates may have faces
* `consult-grep' fontifies the prompt
---
vertico.el | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/vertico.el b/vertico.el
index 0eced70..5eb284e 100644
--- a/vertico.el
+++ b/vertico.el
@@ -301,14 +301,14 @@
(defun vertico--flatten-string (prop str)
"Flatten STR with display or invisible PROP."
- (let ((len (length str)) (pos 0) (chunks))
- (while (/= pos len)
- (let ((end (next-single-property-change pos prop str len)))
+ (let ((end (length str)) (pos 0) (chunks))
+ (while (< pos end)
+ (let ((next (next-single-property-change pos prop str end)))
(if-let (val (get-text-property pos prop str))
(when (and (eq prop 'display) (stringp val))
(push val chunks))
- (push (substring str pos end) chunks))
- (setq pos end)))
+ (push (substring str pos next) chunks))
+ (setq pos next)))
(apply #'concat (nreverse chunks))))
(defun vertico--format-candidates (content bounds metadata)
@@ -397,9 +397,17 @@
(defun vertico--prompt-selection ()
"Highlight the prompt if selected."
(let ((inhibit-modification-hooks t))
- (if (or (>= vertico--index 0) (vertico--require-match))
- (remove-text-properties (minibuffer-prompt-end) (point-max) '(face
nil))
- (add-text-properties (minibuffer-prompt-end) (point-max) '(face
vertico-current)))))
+ (vertico--add-face 'vertico-current (minibuffer-prompt-end) (point-max)
+ (and (< vertico--index 0) (not
(vertico--require-match))))))
+
+(defun vertico--add-face (face beg end add)
+ "Add FACE between BEG and END depending if ADD is t, otherwise remove."
+ (while (< beg end)
+ (let* ((val (get-text-property beg 'face))
+ (faces (remq face (if (listp val) val (list val))))
+ (next (next-single-property-change beg 'face nil end)))
+ (add-text-properties beg next `(face ,(if add (cons face faces) faces)))
+ (setq beg next))))
(defun vertico--exhibit ()
"Exhibit completion UI."
- [elpa] externals/vertico updated (5aaa5f6 -> 424a7e0), Protesilaos Stavrou, 2021/04/10
- [elpa] externals/vertico 48472e9 1/7: README: Mention the copyright assignment, Protesilaos Stavrou, 2021/04/10
- [elpa] externals/vertico 53da8b8 3/7: Truncate lines and resize manually (Fix #5), Protesilaos Stavrou, 2021/04/10
- [elpa] externals/vertico 81b3e3b 4/7: Respect `resize-mini-windows' set to nil, Protesilaos Stavrou, 2021/04/10
- [elpa] externals/vertico 424a7e0 7/7: README: Fix invalid keybindings, Protesilaos Stavrou, 2021/04/10
- [elpa] externals/vertico 412a656 6/7: Always add cursor space to the overlay, Protesilaos Stavrou, 2021/04/10
- [elpa] externals/vertico 486d426 2/7: Pass lines to `vertico--display-candidates`, Protesilaos Stavrou, 2021/04/10
- [elpa] externals/vertico 4198389 5/7: vertico--prompt-selection: Preserve existing faces,
Protesilaos Stavrou <=