]> code.delx.au - gnu-emacs-elpa/commitdiff
Intermediate fix for :preselect with visual-line-mode
authorOleh Krehel <ohwoeowho@gmail.com>
Mon, 16 Nov 2015 11:50:42 +0000 (12:50 +0100)
committerOleh Krehel <ohwoeowho@gmail.com>
Mon, 16 Nov 2015 11:54:04 +0000 (12:54 +0100)
* 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

swiper.el

index eec743461e571996de01381d5b102a5d6cf8ef3c..b9722d45559aa35f83e2fc443e98fa324924f443 100644 (file)
--- 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