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

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

[elpa] master 3380b6f 382/399: swiper.el (swiper--avy-goto): Works for s


From: Oleh Krehel
Subject: [elpa] master 3380b6f 382/399: swiper.el (swiper--avy-goto): Works for swiper-isearch
Date: Sat, 20 Jul 2019 14:58:04 -0400 (EDT)

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

    swiper.el (swiper--avy-goto): Works for swiper-isearch
    
    Here `count-lines' is a bit of a `swiper-isearch' specific hack, since
    it has its own format function.
    
    Fixes #2134
---
 swiper.el | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/swiper.el b/swiper.el
index d3d19f9..f004196 100644
--- a/swiper.el
+++ b/swiper.el
@@ -314,17 +314,18 @@
 (defun swiper--avy-goto (candidate)
   (cond ((let ((win (cdr-safe candidate)))
            (and win (window-minibuffer-p win)))
-         (let ((cand-text (save-excursion
-                            (goto-char (car candidate))
-                            (buffer-substring-no-properties
-                             (line-beginning-position)
-                             (line-end-position)))))
-           (ivy-set-index (cl-position-if
-                           (lambda (x) (cl-search x cand-text))
-                           ivy--old-cands))
-           (ivy--exhibit)
-           (ivy-done)
-           (ivy-call)))
+         (let ((nlines (count-lines (point-min) (point-max))))
+           (ivy-set-index
+            (+ (car (ivy--minibuffer-index-bounds
+                     ivy--index ivy--length ivy-height))
+               (line-number-at-pos (car candidate))
+               (if (= nlines (1+ ivy-height))
+                   0
+                 (- ivy-height nlines))
+               -2)))
+         (ivy--exhibit)
+         (ivy-done)
+         (ivy-call))
         ((or (consp candidate)
              (number-or-marker-p candidate))
          (ivy-quit-and-run



reply via email to

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