From: Oleh Krehel Date: Mon, 16 Nov 2015 11:50:42 +0000 (+0100) Subject: Intermediate fix for :preselect with visual-line-mode X-Git-Url: https://code.delx.au/gnu-emacs-elpa/commitdiff_plain/bb68b67b2bc6f95ddf667e4c34eb2902bcbf604b?hp=c4c1878580eddb229cae98b7d02b5804c9bcc330 Intermediate fix for :preselect with visual-line-mode * swiper.el (swiper--ivy): Use `beginning-of-visual-line' and `end-of-visual-line'. This should fix the preselect problem for non-duplicate buffer lines. For duplicate buffer lines, a `visual-line-number-at-pos' function is necessary. I don't currently know how to implement such a function in an efficient way. The naive implementation could be pretty inefficient, comparable to doubling `swiper' startup time with `visual-line-mode'. Re #291 --- diff --git a/swiper.el b/swiper.el index eec743461..b9722d455 100644 --- a/swiper.el +++ b/swiper.el @@ -343,8 +343,8 @@ When non-nil, INITIAL-INPUT is the initial search pattern." (preselect (if (bound-and-true-p visual-line-mode) (concat " " (buffer-substring-no-properties - (line-beginning-position) - (line-end-position))) + (save-excursion (beginning-of-visual-line) (point)) + (save-excursion (end-of-visual-line) (point)))) (1- (line-number-at-pos)))) (minibuffer-allow-text-properties t)) (unwind-protect