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

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

[elpa] master 341b5a2 229/272: counsel-grep should pick candidates close


From: Oleh Krehel
Subject: [elpa] master 341b5a2 229/272: counsel-grep should pick candidates closest to point
Date: Mon, 25 Apr 2016 10:13:27 +0000

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

    counsel-grep should pick candidates closest to point
    
    * ivy.el (ivy-recompute-index-swiper-async): Update.
    
    Fixes the algorithm selecting the first matching candidate in case there
    are 0 matching candidates following point. Now the last matching
    candidate will be selected, resulting in less scrolling.
---
 ivy.el |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/ivy.el b/ivy.el
index 415f54a..16e7d7f 100644
--- a/ivy.el
+++ b/ivy.el
@@ -2242,10 +2242,13 @@ Prefix matches to NAME are put ahead of the list."
   (if (null ivy--old-cands)
       (let ((ln (with-ivy-window
                   (line-number-at-pos))))
-        (or (cl-position-if (lambda (x)
-                              (>= (string-to-number x) ln))
-                            cands)
-            0))
+        (or
+         ;; closest to current line going forwards
+         (cl-position-if (lambda (x)
+                           (>= (string-to-number x) ln))
+                         cands)
+         ;; closest to current line going backwards
+         (1- (length cands))))
     (let ((tail (nthcdr ivy--index ivy--old-cands))
           idx)
       (if (and tail ivy--old-cands (not (equal "^" ivy--old-re)))



reply via email to

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