[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 8df253a 249/399: swiper.el (swiper--isearch-same-line-p):
From: |
Oleh Krehel |
Subject: |
[elpa] master 8df253a 249/399: swiper.el (swiper--isearch-same-line-p): Add |
Date: |
Sat, 20 Jul 2019 14:57:34 -0400 (EDT) |
branch: master
commit 8df253a942f684688a236f0c7a54eaad64a863bb
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
swiper.el (swiper--isearch-same-line-p): Add
Fixes #2069
---
swiper.el | 88 ++++++++++++++++++++++++++++++++++++---------------------------
1 file changed, 50 insertions(+), 38 deletions(-)
diff --git a/swiper.el b/swiper.el
index 4cc9bc3..14f8801 100644
--- a/swiper.el
+++ b/swiper.el
@@ -1321,6 +1321,14 @@ When not running `swiper-isearch' already, start it."
:background "#1a4b77" :foreground "black"))
"Face used by `swiper-isearch' for highlighting the current match.")
+(defun swiper--isearch-same-line-p (s1 s2)
+ "Check if S1 and S2 are equal and on the same line."
+ (and (equal s1 s2)
+ (<= (count-lines
+ (get-text-property 0 'point s2)
+ (get-text-property 0 'point s1))
+ 1)))
+
(defun swiper-isearch-format-function (_cands)
(let* ((half-height (/ ivy-height 2))
(current (ivy-state-current ivy-last))
@@ -1328,44 +1336,48 @@ When not running `swiper-isearch' already, start it."
(j 0)
(len 0)
res s)
- (while (and (>= i 0)
- (string= (nth i ivy--old-cands)
- current))
- (cl-decf i)
- (cl-incf j))
- (while (and (>= i 0)
- (< len half-height))
- (setq s (nth i ivy--old-cands))
- (unless (equal s (car res))
- (push (ivy--format-minibuffer-line s) res)
- (cl-incf len))
- (cl-decf i))
- (setq res (nreverse res))
- (let ((current-str
- (ivy--add-face
- (ivy--format-minibuffer-line current)
- 'ivy-current-match))
- (start 0))
- (dotimes (_ (1+ j))
- (string-match ivy--old-re current-str start)
- (setq start (match-end 0)))
- (ivy-add-face-text-property
- (match-beginning 0) (match-end 0)
- 'swiper-isearch-current-match current-str)
- (push current-str res))
- (cl-incf len)
- (setq i (1+ ivy--index))
- (while (and (< i ivy--length)
- (string= (nth i ivy--old-cands) current))
- (cl-incf i))
- (while (and (< i ivy--length)
- (< len ivy-height))
- (setq s (nth i ivy--old-cands))
- (unless (equal s (car res))
- (push (ivy--format-minibuffer-line s) res)
- (cl-incf len))
- (cl-incf i))
- (mapconcat #'identity (nreverse res) "\n")))
+ (with-ivy-window
+ (while (and (>= i 0)
+ (swiper--isearch-same-line-p
+ (nth i ivy--old-cands)
+ current))
+ (cl-decf i)
+ (cl-incf j))
+ (while (and (>= i 0)
+ (< len half-height))
+ (setq s (nth i ivy--old-cands))
+ (unless (swiper--isearch-same-line-p s (car res))
+ (push (ivy--format-minibuffer-line s) res)
+ (cl-incf len))
+ (cl-decf i))
+ (setq res (nreverse res))
+ (let ((current-str
+ (ivy--add-face
+ (ivy--format-minibuffer-line current)
+ 'ivy-current-match))
+ (start 0))
+ (dotimes (_ (1+ j))
+ (string-match ivy--old-re current-str start)
+ (setq start (match-end 0)))
+ (ivy-add-face-text-property
+ (match-beginning 0) (match-end 0)
+ 'swiper-isearch-current-match current-str)
+ (push current-str res))
+ (cl-incf len)
+ (setq i (1+ ivy--index))
+ (while (and (< i ivy--length)
+ (swiper--isearch-same-line-p
+ (nth i ivy--old-cands)
+ current))
+ (cl-incf i))
+ (while (and (< i ivy--length)
+ (< len ivy-height))
+ (setq s (nth i ivy--old-cands))
+ (unless (swiper--isearch-same-line-p s (car res))
+ (push (ivy--format-minibuffer-line s) res)
+ (cl-incf len))
+ (cl-incf i))
+ (mapconcat #'identity (nreverse res) "\n"))))
;;;###autoload
(defun swiper-isearch (&optional initial-input)
- [elpa] master e9f0772 218/399: ivy-test.el (counsel-find-file-with-dollars): Adjust, (continued)
- [elpa] master e9f0772 218/399: ivy-test.el (counsel-find-file-with-dollars): Adjust, Oleh Krehel, 2019/07/20
- [elpa] master eee9716 236/399: Add open in dired action to counsel-file-jump, Oleh Krehel, 2019/07/20
- [elpa] master fb64ea3 237/399: swiper.el (swiper-mc): Works for swiper-isearch, Oleh Krehel, 2019/07/20
- [elpa] master 39a9e94 232/399: swiper.el (swiper-isearch-current-match): Add, Oleh Krehel, 2019/07/20
- [elpa] master b7574fe 234/399: swiper.el: Extra condition to recenter in terminal, Oleh Krehel, 2019/07/20
- [elpa] master 10755b2 239/399: swiper.el (swiper-isearch-toggle): Add, Oleh Krehel, 2019/07/20
- [elpa] master 38f8e45 242/399: swiper.el (swiper-isearch-toggle): Fix candidate jump in toggle, Oleh Krehel, 2019/07/20
- [elpa] master d9d6064 241/399: ivy.el (ivy-completion-in-region-action): Obey :exit-function, Oleh Krehel, 2019/07/20
- [elpa] master 6075a73 243/399: swiper.el (swiper--add-overlays): Reuse swiper--add-overlay, Oleh Krehel, 2019/07/20
- [elpa] master 687aae2 246/399: swiper.el (swiper-query-replace): Check for empty input, Oleh Krehel, 2019/07/20
- [elpa] master 8df253a 249/399: swiper.el (swiper--isearch-same-line-p): Add,
Oleh Krehel <=
- [elpa] master 773ac65 245/399: swiper.el (swiper--cleanup): Re-use lazy-highlight-cleanup, Oleh Krehel, 2019/07/20
- [elpa] master 815f094 252/399: swiper.el (swiper--add-line-overlay): Extract, Oleh Krehel, 2019/07/20
- [elpa] master eb1e636 253/399: swiper.el (swiper--add-cursor-overlay): Display only in current window, Oleh Krehel, 2019/07/20
- [elpa] master 7dc1445 256/399: swiper.el (swiper-isearch): Use the same faces in the minibuffer, Oleh Krehel, 2019/07/20
- [elpa] master 4d40f88 255/399: swiper.el (swiper--isearch-function): Speedup for big files, Oleh Krehel, 2019/07/20
- [elpa] master 2ce81eb 240/399: swiper.el (swiper-isearch-toggle): Extend doc, Oleh Krehel, 2019/07/20
- [elpa] master cc92e1c 238/399: swiper.el (swiper--avy-goto): Handle quit, Oleh Krehel, 2019/07/20
- [elpa] master e6f49c2 244/399: swiper.el: Reorder by swiper--overlays, Oleh Krehel, 2019/07/20
- [elpa] master e04b10c 248/399: swiper.el (swiper-isearch-function): Refactor, Oleh Krehel, 2019/07/20
- [elpa] master ee71733 247/399: ivy.el (ivy-switch-buffer-other-window): Fix ivy-use-virtual-buffers, Oleh Krehel, 2019/07/20