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

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

[elpa] master ce6ab7a 135/167: Perform string-match in the original buff


From: Oleh Krehel
Subject: [elpa] master ce6ab7a 135/167: Perform string-match in the original buffer
Date: Tue, 08 Dec 2015 10:50:32 +0000

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

    Perform string-match in the original buffer
    
    * 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 |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/ivy.el b/ivy.el
index 9004477..19fc0e9 100644
--- 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)



reply via email to

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