"Exit the minibuffer with the selected candidate."
(interactive)
(delete-minibuffer-contents)
- (cond ((> ivy--length 0)
+ (cond ((or (> ivy--length 0)
+ ;; the action from `ivy-dispatching-done' may not need a
+ ;; candidate at all
+ (eq this-command 'ivy-dispatching-done))
(ivy--done ivy--current))
((memq (ivy-state-collection ivy-last)
'(read-file-name-internal internal-complete-buffer))
(let ((action (ivy--get-action ivy-last)))
(when action
(let* ((collection (ivy-state-collection ivy-last))
- (x (if (and (consp collection)
- (consp (car collection)))
- (cdr (assoc ivy--current collection))
- (if (equal ivy--current "")
- ivy-text
- ivy--current))))
+ (x (cond ((and (consp collection)
+ (consp (car collection))
+ (cdr (assoc ivy--current collection))))
+ ((equal ivy--current "")
+ ivy-text)
+ (t
+ ivy--current))))
(prog1 (funcall action x)
(unless (or (eq ivy-exit 'done)
(equal (selected-window)
(= ivy--length 1)
(not (string= ivy-text "/")))
(let ((default-directory ivy--directory))
- (file-directory-p ivy--current)))
+ (and
+ (not (equal ivy--current ""))
+ (file-directory-p ivy--current)
+ (file-exists-p ivy--current))))
(ivy--cd (expand-file-name ivy--current ivy--directory)))))
(defun ivy--exhibit ()
start end 'face face str)))
(defun ivy--format-minibuffer-line (str)
- (let ((start 0)
+ (let ((start
+ (if (and (memq (ivy-state-caller ivy-last)
+ '(counsel-git-grep counsel-ag counsel-pt))
+ (string-match "^[^:]+:[^:]+:" str))
+ (match-end 0)
+ 0))
(str (copy-sequence str)))
(cond ((eq ivy--regex-function 'ivy--regex-ignore-order)
(when (consp ivy--old-re)