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

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

[elpa] master 8482f62 179/399: swiper.el (swiper-isearch-function): Fix


From: Oleh Krehel
Subject: [elpa] master 8482f62 179/399: swiper.el (swiper-isearch-function): Fix str is " "
Date: Sat, 20 Jul 2019 14:57:19 -0400 (EDT)

branch: master
commit 8482f621e568716d8f5d765427af58456588e80d
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    swiper.el (swiper-isearch-function): Fix str is " "
    
    Fixes #2018
---
 swiper.el | 61 +++++++++++++++++++++++++++++++------------------------------
 1 file changed, 31 insertions(+), 30 deletions(-)

diff --git a/swiper.el b/swiper.el
index 302bae4..2df423a 100644
--- a/swiper.el
+++ b/swiper.el
@@ -1205,36 +1205,36 @@ come back to the same place as when \"a\" was initially 
entered.")
 
 (defun swiper-isearch-function (str)
   "Collect STR matches in the current buffer for `swiper-isearch'."
-  (unless (string= str "")
-    (let* ((re-full (funcall ivy--regex-function str))
-           (re (ivy-re-to-str re-full))
-           (re (if (string-match "\\`\\(.*\\)[\\]|\\'" re)
-                   (match-string 1 re)
-                 re))
-           (pt-hist (cdr (assoc str swiper--isearch-point-history)))
-           cands
-           idx-found
-           (idx 0))
-      (with-ivy-window
-        (save-excursion
-          (goto-char (point-min))
-          (while (re-search-forward re nil t)
-            (unless idx-found
-              (when (or
-                     (eq (match-beginning 0) pt-hist)
-                     (>= (match-beginning 0) (cdar 
swiper--isearch-point-history)))
-                (push (cons str (match-beginning 0)) 
swiper--isearch-point-history)
-                (setq idx-found idx)))
-            (cl-incf idx)
-            (let ((line (buffer-substring
-                         (line-beginning-position)
-                         (line-end-position))))
-              (put-text-property 0 1 'point (point) line)
-              (push line cands)))))
-      (setq ivy--old-re re)
-      (when idx-found
-        (ivy-set-index idx-found))
-      (setq ivy--old-cands (nreverse cands)))))
+  (let* ((re-full (funcall ivy--regex-function str))
+         (re (ivy-re-to-str re-full)))
+    (unless (string= re "")
+      (let ((re (if (string-match "\\`\\(.*\\)[\\]|\\'" re)
+                    (match-string 1 re)
+                  re))
+            (pt-hist (cdr (assoc str swiper--isearch-point-history)))
+            cands
+            idx-found
+            (idx 0))
+        (with-ivy-window
+          (save-excursion
+            (goto-char (point-min))
+            (while (re-search-forward re nil t)
+              (unless idx-found
+                (when (or
+                       (eq (match-beginning 0) pt-hist)
+                       (>= (match-beginning 0) (cdar 
swiper--isearch-point-history)))
+                  (push (cons str (match-beginning 0)) 
swiper--isearch-point-history)
+                  (setq idx-found idx)))
+              (cl-incf idx)
+              (let ((line (buffer-substring
+                           (line-beginning-position)
+                           (line-end-position))))
+                (put-text-property 0 1 'point (point) line)
+                (push line cands)))))
+        (setq ivy--old-re re)
+        (when idx-found
+          (ivy-set-index idx-found))
+        (setq ivy--old-cands (nreverse cands))))))
 
 (defun swiper--add-cursor-overlay ()
   (let ((ov (make-overlay (point) (if (eolp) (point) (1+ (point))))))
@@ -1256,6 +1256,7 @@ come back to the same place as when \"a\" was initially 
entered.")
           (swiper--add-cursor-overlay)))
     (swiper--cleanup)))
 
+;;;###autoload
 (defun swiper-isearch (&optional initial-input)
   "A `swiper' that's not line-based."
   (interactive)



reply via email to

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