]> code.delx.au - gnu-emacs-elpa/commitdiff
Perform string-match in the original buffer
authorOleh Krehel <ohwoeowho@gmail.com>
Sun, 22 Nov 2015 12:59:27 +0000 (13:59 +0100)
committerOleh Krehel <ohwoeowho@gmail.com>
Sun, 22 Nov 2015 13:01:28 +0000 (14:01 +0100)
* ivy.el (ivy--exhibit): Wrap in `with-current-buffer'
  `ivy-state-buffer'.
(ivy-recompute-index-swiper): Reset to the candidate at the current line
number, in case the previous regex resulted in 0 candidates.

Fixes #298

ivy.el

diff --git a/ivy.el b/ivy.el
index 9004477b71149049a16daec6f1889f5d55b34ed4..19fc0e9ccfba9a0b8fd2e4ee3b87be1eff5f99db 100644 (file)
--- a/ivy.el
+++ b/ivy.el
@@ -1594,8 +1594,9 @@ Should be run via minibuffer `post-command-hook'."
                        (ivy--buffer-list "" ivy-use-virtual-buffers)))
                (setq ivy--old-re nil))))
       (ivy--insert-minibuffer
-       (ivy--format
-        (ivy--filter ivy-text ivy--all-candidates)))
+       (with-current-buffer (ivy-state-buffer ivy-last)
+         (ivy--format
+          (ivy--filter ivy-text ivy--all-candidates))))
       (setq ivy--old-text ivy-text))))
 
 (defun ivy--insert-minibuffer (text)
@@ -1823,7 +1824,17 @@ Prefix matches to NAME are put ahead of the list."
             ;; Compare with eq to handle equal duplicates in cands
             (setq idx (cl-position (pop tail) cands)))
           (or idx 0))
-      ivy--index)))
+      (if ivy--old-cands
+          ivy--index
+        ;; already in ivy-state-buffer
+        (let ((n (line-number-at-pos))
+              (res 0)
+              (i 0))
+          (dolist (c cands)
+            (when (eq n (read (get-text-property 0 'display c)))
+              (setq res i))
+            (cl-incf i))
+          res)))))
 
 (defun ivy-recompute-index-zero (_re-str _cands)
   0)