branch: externals/swiper
commit 8bf8027e4bd8c093bddb76a813952d2a0dcbf21d
Author: Severin Kempf <[email protected]>
Commit: Basil L. Contovounesios <[email protected]>

    Fix swiper preselect when initial-input specified
    
    When swiper is called with an initial-input and the current point is
    on a line that does not contain a match, the previous code would
    return nil for preselect, which would position the first viable
    candidate as the first candidate in the buffer.
    
    This small change selects the first candidate at or following the
    current point, which allows for a simple repeat-search function to
    wrap a call to swiper.
    
    * swiper.el (swiper): Fix preselect search condition (PR #2930).
    
    Copyright-paperwork-exempt: yes
---
 swiper.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/swiper.el b/swiper.el
index f3bebab854..ba9ed6b9c6 100644
--- a/swiper.el
+++ b/swiper.el
@@ -816,7 +816,7 @@ When non-nil, INITIAL-INPUT is the initial search pattern."
                    (if initial-input
                        (cl-position-if
                         (lambda (x)
-                          (= (1+ preselect) (swiper--line-number x)))
+                          (<= (1+ preselect) (swiper--line-number x)))
                         (progn
                           (setq ivy--old-re nil)
                           (ivy--filter initial-input candidates)))

Reply via email to