branch: externals/ivy-hydra
commit e1cfd328cdcdde926a733600325a5b924586885d
Author: Ingo Lohmar <[email protected]>
Commit: Oleh Krehel <[email protected]>
ivy.el (ivy-use-group-face-if-no-groups): New defcustom
Fixes #2324.
Simplify the logic which face is used for what part of the minibuffer
matches.
This only applies to highlighting functions that highlight the whole
match.
---
ivy.el | 11 ++++++++++-
swiper.el | 2 +-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/ivy.el b/ivy.el
index 343ba77..35dec60 100644
--- a/ivy.el
+++ b/ivy.el
@@ -3866,6 +3866,14 @@ Note: The usual last two arguments are flipped for
convenience.")
(cons (flx-score str flx-name ivy--flx-cache) str)))
(ivy--highlight-default str)))
+(defcustom ivy-use-group-face-if-no-groups t
+ "If t, and the expression has no subgroups, highlight whole match as a group.
+
+It will then use the second face (first of the \"group\" faces)
+of `ivy-minibuffer-faces'. Otherwise, always use the first face
+in this case."
+ :type 'boolean)
+
(defun ivy--highlight-default (str)
"Highlight STR, using the default method."
(unless ivy--old-re
@@ -3890,7 +3898,8 @@ Note: The usual last two arguments are flipped for
convenience.")
(unless (and prev (= prev beg))
(cl-incf n))
(let ((face
- (cond ((zerop ivy--subexps)
+ (cond ((and ivy-use-group-face-if-no-groups
+ (zerop ivy--subexps))
(cadr ivy-minibuffer-faces))
((zerop i)
(car ivy-minibuffer-faces))
diff --git a/swiper.el b/swiper.el
index 3f2ec3c..21ddb8e 100644
--- a/swiper.el
+++ b/swiper.el
@@ -1036,7 +1036,7 @@ WND, when specified is the window."
(unless (> (- me mb) 2017)
(funcall adder-fn
mb me
- (if (zerop ivy--subexps)
+ (if (and ivy-use-group-face-if-no-groups (zerop ivy--subexps))
(nth (1+ (mod (or re-idx 0) (1- (length faces)))) faces)
(car faces))
0)))