branch: master
commit 63f349821c88ccbb6379ac8f0df08bb8f1bea518
Author: Oleh Krehel <ohwoeo...@gmail.com>
Commit: Oleh Krehel <ohwoeo...@gmail.com>

    Add precise preselect for swiper with visual-line-mode
    
    * swiper.el (swiper--ivy): Use `count-screen-lines' to calculate the
      visual line number.
    
    Fixes #291
---
 swiper.el |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/swiper.el b/swiper.el
index b9722d4..216a50a 100644
--- a/swiper.el
+++ b/swiper.el
@@ -342,9 +342,9 @@ When non-nil, INITIAL-INPUT is the initial search pattern."
   (let ((candidates (swiper--candidates))
         (preselect
          (if (bound-and-true-p visual-line-mode)
-             (concat " " (buffer-substring-no-properties
-                          (save-excursion (beginning-of-visual-line) (point))
-                          (save-excursion (end-of-visual-line) (point))))
+             (count-screen-lines
+              (point-min)
+              (save-excursion (beginning-of-visual-line) (point)))
            (1- (line-number-at-pos))))
         (minibuffer-allow-text-properties t))
     (unwind-protect

Reply via email to