[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master ccbf9ef 204/272: Improve counsel-async initial anchoring
From: |
Oleh Krehel |
Subject: |
[elpa] master ccbf9ef 204/272: Improve counsel-async initial anchoring |
Date: |
Mon, 25 Apr 2016 10:13:25 +0000 |
branch: master
commit ccbf9efc66c5fc4ae34503e90bbdb147cac233f5
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Improve counsel-async initial anchoring
* counsel.el (counsel--async-sentinel): Rely on
`ivy-recompute-index-swiper-async' even when `ivy--old-cands' is nil.
* ivy.el (ivy--recompute-index): Check for `ivy--old-cands' being nil
before trying to index it.
(ivy-recompute-index-swiper-async): When `ivy--old-cands' is nil, look
for a string that's closest to the line number at point.
---
counsel.el | 18 +++++++++---------
ivy.el | 29 ++++++++++++++++++-----------
2 files changed, 27 insertions(+), 20 deletions(-)
diff --git a/counsel.el b/counsel.el
index f2607a4..ebdca2f 100644
--- a/counsel.el
+++ b/counsel.el
@@ -118,15 +118,15 @@ Or the time of the last minibuffer update.")
(ivy--set-candidates
(ivy--sort-maybe
cands))
- (if (null ivy--old-cands)
- (setq ivy--index
- (or (ivy--preselect-index
- (ivy-state-preselect ivy-last)
- ivy--all-candidates)
- 0))
- (let ((re (funcall ivy--regex-function ivy-text)))
- (unless (stringp re)
- (setq re (caar re)))
+ (let ((re (funcall ivy--regex-function ivy-text)))
+ (unless (stringp re)
+ (setq re (caar re)))
+ (if (null ivy--old-cands)
+ (unless (setq ivy--index (ivy--preselect-index
+ (ivy-state-preselect ivy-last)
+ ivy--all-candidates))
+ (ivy--recompute-index
+ ivy-text re ivy--all-candidates))
(ivy--recompute-index
ivy-text re ivy--all-candidates)))
(setq ivy--old-cands ivy--all-candidates)
diff --git a/ivy.el b/ivy.el
index 1d7fcb3..37648bb 100644
--- a/ivy.el
+++ b/ivy.el
@@ -2189,7 +2189,7 @@ Prefix matches to NAME are put ahead of the list."
(not (and (require 'flx nil 'noerror)
(eq ivy--regex-function 'ivy--regex-fuzzy)
(< (length cands) 200)))
-
+ ivy--old-cands
(cl-position (nth ivy--index ivy--old-cands)
cands))
(funcall func re-str cands))))
@@ -2226,16 +2226,23 @@ Prefix matches to NAME are put ahead of the list."
res)))))
(defun ivy-recompute-index-swiper-async (_re-str cands)
- (let ((tail (nthcdr ivy--index ivy--old-cands))
- idx)
- (if (and tail ivy--old-cands (not (equal "^" ivy--old-re)))
- (progn
- (while (and tail (null idx))
- ;; Compare with `equal', since the collection is re-created
- ;; each time with `split-string'
- (setq idx (cl-position (pop tail) cands :test #'equal)))
- (or idx 0))
- ivy--index)))
+ (if (null ivy--old-cands)
+ (let ((ln (with-ivy-window
+ (line-number-at-pos))))
+ (or (cl-position-if (lambda (x)
+ (>= (string-to-number x) ln))
+ cands)
+ 0))
+ (let ((tail (nthcdr ivy--index ivy--old-cands))
+ idx)
+ (if (and tail ivy--old-cands (not (equal "^" ivy--old-re)))
+ (progn
+ (while (and tail (null idx))
+ ;; Compare with `equal', since the collection is re-created
+ ;; each time with `split-string'
+ (setq idx (cl-position (pop tail) cands :test #'equal)))
+ (or idx 0))
+ ivy--index))))
(defun ivy-recompute-index-zero (_re-str _cands)
0)
- [elpa] master 6757030 225/272: counsel-grep now works with ivy-occur-revert-buffer, (continued)
- [elpa] master 6757030 225/272: counsel-grep now works with ivy-occur-revert-buffer, Oleh Krehel, 2016/04/25
- [elpa] master 6026caf 174/272: counsel.el (counsel-locate-cmd-es): Add, Oleh Krehel, 2016/04/25
- [elpa] master 7ed5b06 119/272: ivy.el (ivy--preselect-index): Don't use regexp-quote, Oleh Krehel, 2016/04/25
- [elpa] master dcf4957 123/272: counsel.el (counsel--async-command): Add sentinel and filter args, Oleh Krehel, 2016/04/25
- [elpa] master 53ca6ed 065/272: ivy.el (ivy-do-completion-in-region): New defcustom, Oleh Krehel, 2016/04/25
- [elpa] master ca2b47f 240/272: Add timing information to async commands, Oleh Krehel, 2016/04/25
- [elpa] master d544427 093/272: swiper.el (swiper--re-builder): Replace \t with 4 spaces, Oleh Krehel, 2016/04/25
- [elpa] master 1f3ea7d 095/272: ivy.el (ivy-next-history-element): Handle "M-n M-n" better, Oleh Krehel, 2016/04/25
- [elpa] master ab3ad4e 085/272: doc/ivy.org: Add more CUSTOM_ID, Oleh Krehel, 2016/04/25
- [elpa] master 725e19a 170/272: counsel.el (counsel-ag-occur): Add, Oleh Krehel, 2016/04/25
- [elpa] master ccbf9ef 204/272: Improve counsel-async initial anchoring,
Oleh Krehel <=
- [elpa] master 2fb8d86 260/272: ivy.el (ivy-done): Allow ivy-dispatching-done to exit with no cands, Oleh Krehel, 2016/04/25
- [elpa] master 1c68495 145/272: ivy.el (ivy-expand-file-if-directory): New defun, Oleh Krehel, 2016/04/25
- [elpa] master d4fc54b 110/272: ivy-test.el (counsel-unquote-regex-parens): Add test, Oleh Krehel, 2016/04/25
- [elpa] master 5f0d175 172/272: counsel.el (counsel-prompt-function-dir): Make portable, Oleh Krehel, 2016/04/25
- [elpa] master 5765208 185/272: counsel.el (counsel-pt-base-command): Add regex flag, Oleh Krehel, 2016/04/25
- [elpa] master 67ac850 211/272: counsel.el (counsel-M-x): Add help action, Oleh Krehel, 2016/04/25
- [elpa] master 189c093 207/272: counsel.el (counsel-ace-link): New command, Oleh Krehel, 2016/04/25
- [elpa] master 8c2f213 059/272: counsel.el (counsel-yank-pop): Truncate during display, Oleh Krehel, 2016/04/25
- [elpa] master 5c2c1df 166/272: counsel.el (counsel-git-grep-map): Bind "C-c C-m" to counsel-git-grep-switch-cmd, Oleh Krehel, 2016/04/25
- [elpa] master e6f92fd 191/272: ivy.el (ivy-occur-press): Add counsel-describe-function, Oleh Krehel, 2016/04/25