emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 39a9e94 232/399: swiper.el (swiper-isearch-current-match):


From: Oleh Krehel
Subject: [elpa] master 39a9e94 232/399: swiper.el (swiper-isearch-current-match): Add
Date: Sat, 20 Jul 2019 14:57:29 -0400 (EDT)

branch: master
commit 39a9e94d530c3d209f367e1aefe313b696100248
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    swiper.el (swiper-isearch-current-match): Add
    
    Fixes #2034
---
 swiper.el | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/swiper.el b/swiper.el
index 358e2c6..62a8907 100644
--- a/swiper.el
+++ b/swiper.el
@@ -1301,16 +1301,25 @@ When not running `swiper-isearch' already, start it."
     map)
   "Keymap for `swiper-isearch'.")
 
+(defface swiper-isearch-current-match
+  '((((class color) (background light))
+     :background "#65a7e2" :foreground "white")
+    (((class color) (background dark))
+     :background "#1a4b77" :foreground "black"))
+  "Face used by `swiper-isearch' for highlighting the current match.")
+
 (defun swiper-isearch-format-function (_cands)
   (let* ((half-height (/ ivy-height 2))
          (current (ivy-state-current ivy-last))
          (i (1- ivy--index))
+         (j 0)
          (len 0)
          res s)
     (while (and (>= i 0)
                 (string= (nth i ivy--old-cands)
                          current))
-      (cl-decf i))
+      (cl-decf i)
+      (cl-incf j))
     (while (and (>= i 0)
                 (< len half-height))
       (setq s (nth i ivy--old-cands))
@@ -1319,7 +1328,18 @@ When not running `swiper-isearch' already, start it."
         (cl-incf len))
       (cl-decf i))
     (setq res (nreverse res))
-    (push (ivy--add-face (ivy--format-minibuffer-line current) 
'ivy-current-match) res)
+    (let ((current-str
+           (ivy--add-face
+            (ivy--format-minibuffer-line current)
+            'ivy-current-match))
+          (start 0))
+      (dotimes (_ (1+ j))
+        (string-match ivy--old-re current-str start)
+        (setq start (match-end 0)))
+      (ivy-add-face-text-property
+       (match-beginning 0) (match-end 0)
+       'swiper-isearch-current-match current-str)
+      (push current-str res))
     (cl-incf len)
     (setq i (1+ ivy--index))
     (while (and (< i ivy--length)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]