[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master c4c1878 121/167: Fix swiper preselect issue with similar o
From: |
Oleh Krehel |
Subject: |
[elpa] master c4c1878 121/167: Fix swiper preselect issue with similar or identical lines |
Date: |
Tue, 08 Dec 2015 10:50:26 +0000 |
branch: master
commit c4c1878580eddb229cae98b7d02b5804c9bcc330
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Fix swiper preselect issue with similar or identical lines
* ivy.el (ivy--preselect-index): Allow PRESELECT to be an integer.
* swiper.el (swiper--anchor):
(swiper--len): Remove unused defvar.
(swiper--init): Update.
(swiper--ivy): Set PRESELECT to `line-number-at-pos'.
Fixes #290
---
ivy.el | 16 +++++++++-------
swiper.el | 43 +++++++++++++++++++------------------------
2 files changed, 28 insertions(+), 31 deletions(-)
diff --git a/ivy.el b/ivy.el
index bf89836..92b87fd 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1293,13 +1293,15 @@ When MATCHER is non-nil it's used instead of
`cl-remove-if-not'."
candidates))))
(when matcher
(setq candidates (funcall matcher "" candidates))))
- (or (cl-position preselect candidates :test #'equal)
- (and (stringp preselect)
- (let ((re (regexp-quote preselect)))
- (cl-position-if
- (lambda (x)
- (string-match re x))
- candidates)))))
+ (cond ((integerp preselect)
+ preselect)
+ ((cl-position preselect candidates :test #'equal))
+ ((stringp preselect)
+ (let ((re (regexp-quote preselect)))
+ (cl-position-if
+ (lambda (x)
+ (string-match re x))
+ candidates)))))
;;* Implementation
;;** Regex
diff --git a/swiper.el b/swiper.el
index 56247ed..eec7434 100644
--- a/swiper.el
+++ b/swiper.el
@@ -298,19 +298,11 @@ When non-nil, INITIAL-INPUT is the initial search
pattern."
(interactive)
(swiper--ivy initial-input))
-(defvar swiper--anchor nil
- "A line number to which the search should be anchored.")
-
-(defvar swiper--len 0
- "The last length of input for which an anchoring was made.")
-
(declare-function evil-jumper--set-jump "ext:evil-jumper")
(defun swiper--init ()
"Perform initialization common to both completion methods."
(setq swiper--opoint (point))
- (setq swiper--len 0)
- (setq swiper--anchor (line-number-at-pos))
(when (bound-and-true-p evil-jumper-mode)
(evil-jumper--set-jump)))
@@ -348,24 +340,27 @@ When non-nil, INITIAL-INPUT is the initial search
pattern."
(setq swiper-invocation-face
(plist-get (text-properties-at (point)) 'face))
(let ((candidates (swiper--candidates))
- (preselect (buffer-substring-no-properties
- (line-beginning-position)
- (line-end-position)))
+ (preselect
+ (if (bound-and-true-p visual-line-mode)
+ (concat " " (buffer-substring-no-properties
+ (line-beginning-position)
+ (line-end-position)))
+ (1- (line-number-at-pos))))
(minibuffer-allow-text-properties t))
(unwind-protect
- (ivy-read
- "Swiper: "
- candidates
- :initial-input initial-input
- :keymap swiper-map
- :preselect preselect
- :require-match t
- :update-fn #'swiper--update-input-ivy
- :unwind #'swiper--cleanup
- :action #'swiper--action
- :re-builder #'swiper--re-builder
- :history 'swiper-history
- :caller 'swiper)
+ (ivy-read
+ "Swiper: "
+ candidates
+ :initial-input initial-input
+ :keymap swiper-map
+ :preselect preselect
+ :require-match t
+ :update-fn #'swiper--update-input-ivy
+ :unwind #'swiper--cleanup
+ :action #'swiper--action
+ :re-builder #'swiper--re-builder
+ :history 'swiper-history
+ :caller 'swiper)
(when (null ivy-exit)
(goto-char swiper--opoint)))))
- [elpa] master b39e20c 102/167: ivy.el (ivy-alt-done): Ensure the trailing slash for directories, (continued)
- [elpa] master b39e20c 102/167: ivy.el (ivy-alt-done): Ensure the trailing slash for directories, Oleh Krehel, 2015/12/08
- [elpa] master d89abf2 104/167: counsel.el (counsel--find-symbol): Silence byte compiler, Oleh Krehel, 2015/12/08
- [elpa] master c4562e0 109/167: swiper.el (swiper-font-lock-ensure): Add occur-mode, Oleh Krehel, 2015/12/08
- [elpa] master 5d90542 112/167: ivy.el (ivy-sort-functions-alist): Update doc, Oleh Krehel, 2015/12/08
- [elpa] master adac116 126/167: Make ivy-completing-read handle history as cons, Oleh Krehel, 2015/12/08
- [elpa] master c580fe9 108/167: ivy.el (ivy-occur): Give full counsel-git-grep cands, Oleh Krehel, 2015/12/08
- [elpa] master bb68b67 122/167: Intermediate fix for :preselect with visual-line-mode, Oleh Krehel, 2015/12/08
- [elpa] master 5751119 124/167: README.md: Add more bindings, Oleh Krehel, 2015/12/08
- [elpa] master e47ec14 128/167: ivy.el (ivy-completing-read): Fix off by one, Oleh Krehel, 2015/12/08
- [elpa] master d5489af 100/167: doc/ivy.org: Start writing a manual, Oleh Krehel, 2015/12/08
- [elpa] master c4c1878 121/167: Fix swiper preselect issue with similar or identical lines,
Oleh Krehel <=
- [elpa] master 7397bec 114/167: Allow user-specified matched candidate sorting, Oleh Krehel, 2015/12/08
- [elpa] master ce557d1 119/167: swiper.el (swiper--candidates): Replace "\t" with " ", Oleh Krehel, 2015/12/08
- [elpa] master 5a99dda 118/167: ivy.el (ivy--truncate-string): New defun, Oleh Krehel, 2015/12/08
- [elpa] master 3101efd 136/167: swiper.el (swiper--action): push-mark only if exited the minibuffer, Oleh Krehel, 2015/12/08
- [elpa] master 63f3498 123/167: Add precise preselect for swiper with visual-line-mode, Oleh Krehel, 2015/12/08
- [elpa] master 74bb138 144/167: Update ivy format functions., Oleh Krehel, 2015/12/08
- [elpa] master 39e6733 129/167: Improve ivy TRAMP support, Oleh Krehel, 2015/12/08
- [elpa] master 63e714c 130/167: Allow access to TRAMP from "// C-j", Oleh Krehel, 2015/12/08
- [elpa] master 85bd44b 125/167: swiper.el: Modify the behavior with org-mode and visual-line-mode, Oleh Krehel, 2015/12/08
- [elpa] master 8fdf210 127/167: Switch to using ivy-exit-with-action, Oleh Krehel, 2015/12/08