[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ivy-hydra 84efa3a 262/395: Ensure counsel--git-grep-ind
From: |
Basil L. Contovounesios |
Subject: |
[elpa] externals/ivy-hydra 84efa3a 262/395: Ensure counsel--git-grep-index returns non-nil |
Date: |
Thu, 25 Feb 2021 08:32:16 -0500 (EST) |
branch: externals/ivy-hydra
commit 84efa3a2cbb9c5b0bbcc8d2e90671434eed74f94
Author: Basil L. Contovounesios <contovob@tcd.ie>
Commit: Basil L. Contovounesios <contovob@tcd.ie>
Ensure counsel--git-grep-index returns non-nil
* counsel.el (counsel--git-grep-index): Return a valid non-nil index
even when all the calls to cl-position-if return nil.
Re: #2543
---
counsel.el | 41 +++++++++++++++++++++--------------------
1 file changed, 21 insertions(+), 20 deletions(-)
diff --git a/counsel.el b/counsel.el
index 87c1262..f22976a 100644
--- a/counsel.el
+++ b/counsel.el
@@ -1566,26 +1566,27 @@ When CMD is non-nil, prompt for a specific \"git grep\"
command."
:caller 'counsel-git-grep))))
(defun counsel--git-grep-index (_re-str cands)
- (if (null ivy--old-cands)
- (let ((bname (with-ivy-window (buffer-file-name))))
- (if bname
- (let ((ln (with-ivy-window
- (line-number-at-pos)))
- (name (file-name-nondirectory bname)))
- (or
- ;; closest to current line going forwards
- (cl-position-if (lambda (x)
- (and (string-prefix-p name x)
- (>= (string-to-number
- (substring x (1+ (length name))))
ln)))
- cands)
- ;; closest to current line going backwards
- (cl-position-if (lambda (x)
- (string-prefix-p name x))
- cands
- :from-end t)))
- 0))
- (ivy-recompute-index-swiper-async nil cands)))
+ (let (name ln)
+ (cond
+ (ivy--old-cands
+ (ivy-recompute-index-swiper-async nil cands))
+ ((unless (with-ivy-window
+ (when buffer-file-name
+ (setq ln (line-number-at-pos))
+ (setq name (file-name-nondirectory buffer-file-name))))
+ 0))
+ ;; Closest to current line going forwards.
+ ((let ((beg (1+ (length name))))
+ (cl-position-if (lambda (x)
+ (and (string-prefix-p name x)
+ (>= (string-to-number (substring x beg)) ln)))
+ cands)))
+ ;; Closest to current line going backwards.
+ ((cl-position-if (lambda (x)
+ (string-prefix-p name x))
+ cands
+ :from-end t))
+ (t 0))))
(ivy-configure 'counsel-git-grep
:occur #'counsel-git-grep-occur
- [elpa] externals/ivy-hydra f9fa30d 211/395: More compatibility fixes, (continued)
- [elpa] externals/ivy-hydra f9fa30d 211/395: More compatibility fixes, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 48e56da 305/395: Extend :type of counsel-async-command-delay, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 0eebf24 318/395: ivy.el (ivy--partial-cd-for-single-directory): Fix for ignore-order, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra edefba7 304/395: ivy-test.el (ivy-read-alist-multi-cands): Add test, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra aa47396 218/395: counsel.el (counsel-fonts): Preselect the current font, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 2bf7317 235/395: ivy.el: ivy--index should never be nil, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 33fa992 250/395: Fix swiper handling of bol regex, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 6ab24b6 249/395: * ivy.el: Use with-eval-after-load, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra ffa5a5f 258/395: counsel-describe-symbol: autoload, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 71f5727 261/395: counsel.el (counsel--git-grep-index): Don't error on null buffer-file-name, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 84efa3a 262/395: Ensure counsel--git-grep-index returns non-nil,
Basil L. Contovounesios <=
- [elpa] externals/ivy-hydra 6eda8fa 254/395: Fix recent ivy-auto-shrink-minibuffer-alist typo, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra b40af52 267/395: counsel.el (counsel-find-file-undo): Remap undo, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra fc3252b 274/395: Don't insert ^ on aborting completion in region, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra a4a22e0 294/395: ivy.el (ivy-display-style): Remove, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra ee747e6 290/395: ivy.el (ivy--update-history): Use ivy-state-current for file names, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra f67a2bb 215/395: ivy.el (ivy--filter): Prioritize :matcher, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra ca89b5d 236/395: ivy.el (ivy--recompute-index): Don't call ivy-set-index twice, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra bd80852 251/395: Fix punctuation in some error messages, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 8383dd6 248/395: * counsel.el: Unquote lambda actions, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 6916cbd 256/395: doc/ivy.org: Document ivy-insert-current-full, Basil L. Contovounesios, 2021/02/25