]> code.delx.au - gnu-emacs-elpa/commitdiff
Fix swiper "backward" search
authorOleh Krehel <ohwoeowho@gmail.com>
Mon, 18 Jan 2016 13:10:54 +0000 (14:10 +0100)
committerOleh Krehel <ohwoeowho@gmail.com>
Mon, 18 Jan 2016 13:10:54 +0000 (14:10 +0100)
* ivy.el (ivy-recompute-index-swiper): When none of the previous
  candidates after the point match the current input, instead of
  returning 0, return the index of the last matching candidate.  This is
  a good choice, because that candidate is the closest to the point of
  the initial search start.

Fixes #319

ivy.el

diff --git a/ivy.el b/ivy.el
index e65635d7261d03264583090a1baf68e4c1068d23..bb2aa9955cd6064b00c555facf4dc6b1a75a9b82 100644 (file)
--- a/ivy.el
+++ b/ivy.el
@@ -1998,7 +1998,9 @@ Prefix matches to NAME are put ahead of the list."
           (while (and tail (null idx))
             ;; Compare with eq to handle equal duplicates in cands
             (setq idx (cl-position (pop tail) cands)))
-          (or idx 0))
+          (or
+           idx
+           (1- (length cands))))
       (if ivy--old-cands
           ivy--index
         ;; already in ivy-state-buffer