branch: master
commit e76c43a152d9f3a422acf6390d10f67667ec4711
Author: Chris Perl <[email protected]>
Commit: Oleh Krehel <[email protected]>
Make counsel-git-grep use counsel-delete-process
In counsel-git-grep, when proj is t and we're creating an asynchronous
process, make sure to call counsel-delete-process on unwind. Otherwise,
we might leave the process running if we broke out of the completion
early with ivy-occur.
Fixes #1075
---
counsel.el | 32 +++++++++++++++++++++-----------
1 file changed, 21 insertions(+), 11 deletions(-)
diff --git a/counsel.el b/counsel.el
index 8c49974..85f7166 100644
--- a/counsel.el
+++ b/counsel.el
@@ -1178,17 +1178,27 @@ INITIAL-INPUT can be given as the initial minibuffer
input."
(if (eq system-type 'windows-nt)
0
(counsel--gg-count "" t))))
- (ivy-read "git grep" (if proj
- 'counsel-git-grep-proj-function
- 'counsel-git-grep-function)
- :initial-input initial-input
- :matcher #'counsel-git-grep-matcher
- :dynamic-collection (or proj
counsel-git-grep-skip-counting-lines (> counsel--git-grep-count 20000))
- :keymap counsel-git-grep-map
- :action #'counsel-git-grep-action
- :unwind #'swiper--cleanup
- :history 'counsel-git-grep-history
- :caller 'counsel-git-grep))))
+ (cl-flet
+ ((collection-function
+ (if proj
+ #'counsel-git-grep-proj-function
+ #'counsel-git-grep-function))
+ (unwind-function
+ (if proj
+ (lambda ()
+ (counsel-delete-process)
+ (swiper--cleanup))
+ (lambda ()
+ (swiper--cleanup)))))
+ (ivy-read "git grep" #'collection-function
+ :initial-input initial-input
+ :matcher #'counsel-git-grep-matcher
+ :dynamic-collection (or proj
counsel-git-grep-skip-counting-lines (> counsel--git-grep-count 20000))
+ :keymap counsel-git-grep-map
+ :action #'counsel-git-grep-action
+ :unwind #'unwind-function
+ :history 'counsel-git-grep-history
+ :caller 'counsel-git-grep)))))
(defun counsel-git-grep-proj-function (str)
"Grep for STR in the current git repository."