From 63f349821c88ccbb6379ac8f0df08bb8f1bea518 Mon Sep 17 00:00:00 2001 From: Oleh Krehel Date: Mon, 16 Nov 2015 15:25:12 +0100 Subject: [PATCH] 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 file changed, 3 insertions(+), 3 deletions(-) diff --git a/swiper.el b/swiper.el index b9722d455..216a50a0e 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 -- 2.39.2