[Top][All Lists]

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

[elpa] master 180d329 365/399: swiper.el (swiper--re-builder): Improve f

From: Oleh Krehel
Subject: [elpa] master 180d329 365/399: swiper.el (swiper--re-builder): Improve for char-fold-to-regexp
Date: Sat, 20 Jul 2019 14:58:00 -0400 (EDT)

branch: master
commit 180d3290f636f0fe9dc0ed3a61632fa9b057ac73
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    swiper.el (swiper--re-builder): Improve for char-fold-to-regexp
    - Capture each part into a group
    - Set `ivy--subexps' so that each match group is highlighted
    - Switch from greedy to non-greedy
    * swiper.el (swiper--delayed-add-overlays): Use
      `swiper--positive-regexps' so that `swiper-isearch' highlighting
      works better.
    Fixes #2124
 swiper.el | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/swiper.el b/swiper.el
index c2caeb2..f13ea28 100644
--- a/swiper.el
+++ b/swiper.el
@@ -709,7 +709,12 @@ line numbers.  For the buffer, use `ivy--regex' instead."
                         (setq ivy--subexps 1))
                     (format "^ %s" re))))
                ((eq (bound-and-true-p search-default-mode) 
-                (mapconcat #'char-fold-to-regexp (ivy--split str) ".*"))
+                (let ((subs (ivy--split str)))
+                  (setq ivy--subexps (length subs))
+                  (mapconcat
+                   (lambda (s) (format "\\(%s\\)" (char-fold-to-regexp s)))
+                   subs
+                   ".*?")))
                 (funcall re-builder str)))))
@@ -1331,7 +1336,8 @@ that we search only for one character."
              (lambda ()
                  (swiper--add-overlays (ivy--regex ivy-text))))))
-    (swiper--add-overlays (ivy--regex ivy-text))))
+    (dolist (re (swiper--positive-regexps ivy-text))
+      (swiper--add-overlays re))))
 (defun swiper-isearch-action (x)
   "Move to X for `swiper-isearch'."

reply via email to

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