Skip to content

Ivy Mini-Buffer Match Faces not Consistently Applied #2717

Description

@brownts

I've noticed that the face selection (of ivy-minibuffer-match-face-X) is not consistently applied, as would be expected. When only a single sub-expression is being matched, ivy-minibuffer-match-face-2 is used (due to the default setting of ivy-use-group-face-if-no-groups), however when 2+ sub-expressions exist, the first sub-expression ends up using ivy-minibuffer-match-face-3 instead, and subsequent sub-expressions use face-4, face-2, etc.

I've attached screenshots demonstrating this issue which shows the face selection when only 1 expression exists vs. 2 or 3 expressions. The minimal configuration performed starting from an emacs -Q standpoint is as follows (also shown in the *scratch* buffer in the attachments):

(require 'package)
(package-initialize)
(require 'swiper)

(progn
  (set-face-attribute 'ivy-minibuffer-match-face-2 nil :foreground "white" :background "red")
  (set-face-attribute 'ivy-minibuffer-match-face-3 nil :foreground "white" :background "darkgreen")
  (set-face-attribute 'ivy-minibuffer-match-face-4 nil :foreground "white" :background "blue")
  (set-face-attribute 'swiper-match-face-2         nil :foreground "white" :background "red")
  (set-face-attribute 'swiper-match-face-3         nil :foreground "white" :background "darkgreen")
  (set-face-attribute 'swiper-match-face-4         nil :foreground "white" :background "blue"))

With the above configuration, I've adjusted both the ivy-minibuffer-match-face-X and swiper-match-face-X background/foreground to use the same colors between the mini-buffer and swiper (for easy comparison...swiper faces are consistently applied) and better differentiate between face-2, face-3 and face-4 usage in the mini-buffer.

With that configuration I just opened the *Faces* buffer (i.e., M-x list-faces-display) and performed the searches as demonstrated in the attachments with Swiper (i.e., M-x swiper).

Based on my experimentation, I've classified the application of the faces as follows:

  • ivy-minibuffer-match-face-2
    • 1st sub-expression in match (when single sub-expression)
    • 3rd sub-expression in match (when three sub-expressions)
  • ivy-minibuffer-match-face-3
    • 1st sub-expression in match (when 2 or 3 sub-expressions)
  • ivy-minibuffer-match-face-4
    • 2nd sub-expression in match (when 2 or 3 sub-expressions)

Single sub-expression example (correctly uses ivy-minibuffer-match-face-2):
ivy_minibuffer_faces_1_subexpression

Two sub-expression example (incorrectly uses ivy-minibuffer-match-face-3 first):
ivy_minibuffer_faces_2_subexpressions

Three sub-expression example (incorrectly uses ivy-minibuffer-match-face-3 first):
ivy_minibuffer_faces_3_subexpressions

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions