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

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

[elpa] master 9c53320 174/399: swiper.el (swiper-isearch-function): Fix


From: Oleh Krehel
Subject: [elpa] master 9c53320 174/399: swiper.el (swiper-isearch-function): Fix for strings with trailing \|
Date: Sat, 20 Jul 2019 14:57:18 -0400 (EDT)

branch: master
commit 9c53320f7514415b473dd417daced9fa81f0c231
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    swiper.el (swiper-isearch-function): Fix for strings with trailing \|
    
    Need this because in that case the empty string is a match, and
    `re-search-forward' does not move point. `isearch-forward-regexp' does
    something similar.
    
    * ivy-test.el (swiper-isearch): Add test.
    
    Fixes #2014
---
 ivy-test.el | 16 +++++++++++++++-
 swiper.el   |  3 +++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/ivy-test.el b/ivy-test.el
index 20daa9d..1b9e57a 100644
--- a/ivy-test.el
+++ b/ivy-test.el
@@ -1058,7 +1058,21 @@ a buffer visiting a file."
      "abc\na|sdf123 def\ndem"
      (global-set-key (kbd "C-s") #'swiper-isearch)
      ("C-s" "de" "" "RET"))
-    "abc\nasd|f123 def\ndem")))
+    "abc\nasd|f123 def\ndem"))
+  (should
+   (string=
+    (ivy-with-text
+     "|(defun foo)\nasdf\n(defvar bar)"
+     (global-set-key (kbd "C-s") #'swiper-isearch)
+     ("C-s" "defun\\|defvar" "RET"))
+    "(defun| foo)\nasdf\n(defvar bar)"))
+  (should
+   (string=
+    (ivy-with-text
+     "|(defun foo)\nasdf\n(defvar bar)"
+     (global-set-key (kbd "C-s") #'swiper-isearch)
+     ("C-s" "defun\\|defvar" "C-n RET"))
+    "(defun foo)\nasdf\n(defvar| bar)")))
 
 (ert-deftest ivy-use-selectable-prompt ()
   (let ((ivy-use-selectable-prompt t)
diff --git a/swiper.el b/swiper.el
index 7434b4b..6ea7aa2 100644
--- a/swiper.el
+++ b/swiper.el
@@ -1207,6 +1207,9 @@ come back to the same place as when \"a\" was initially 
entered.")
   (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



reply via email to

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