]> code.delx.au - gnu-emacs-elpa/commitdiff
counsel.el (counsel-grep-action): Improve cleanup
authorOleh Krehel <ohwoeowho@gmail.com>
Sat, 26 Mar 2016 16:15:49 +0000 (17:15 +0100)
committerOleh Krehel <ohwoeowho@gmail.com>
Sat, 26 Mar 2016 16:15:49 +0000 (17:15 +0100)
When the current input goes from matching to non-matching, ensure that
the old overlays are cleaned up.

counsel.el

index e9b706b5aab794c4e03d0db16bf8df705a93b74d..9384262aa752da9548e69767322e914aed3bf228 100644 (file)
@@ -1361,8 +1361,9 @@ This uses `counsel-ag' with `counsel-pt-base-command' replacing
       nil)))
 
 (defun counsel-grep-action (x)
-  (when (string-match "\\`\\([0-9]+\\):\\(.*\\)\\'" x)
-    (with-ivy-window
+  (with-ivy-window
+    (swiper--cleanup)
+    (when (string-match "\\`\\([0-9]+\\):\\(.*\\)\\'" x)
       (let ((file-name counsel--git-grep-dir)
             (line-number (match-string-no-properties 1 x)))
         (find-file file-name)
@@ -1372,7 +1373,6 @@ This uses `counsel-ag' with `counsel-pt-base-command' replacing
         (if (eq ivy-exit 'done)
             (swiper--ensure-visible)
           (unless (eq ivy-exit 'done)
-            (swiper--cleanup)
             (isearch-range-invisible (line-beginning-position)
                                      (line-end-position))
             (swiper--add-overlays (ivy--regex ivy-text))))))))