branch: master
commit 41732be041b004b6d0da4617e9bb019ba13832d9
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>
ivy.el: Return nil when there is no match
* ivy.el (ivy-done): Update.
(ivy-read): Update.
---
ivy.el | 26 ++++++++++++++------------
1 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/ivy.el b/ivy.el
index 62eb20e..5b2ef39 100644
--- a/ivy.el
+++ b/ivy.el
@@ -81,8 +81,9 @@ of `history-length', which see.")
"Exit the minibuffer with the selected candidate."
(interactive)
(delete-minibuffer-contents)
- (insert ivy--current)
- (setq ivy-exit 'done)
+ (unless (zerop ivy--length)
+ (insert ivy--current)
+ (setq ivy-exit 'done))
(exit-minibuffer))
(defun ivy-next-line ()
@@ -155,16 +156,17 @@ If INDEX is non-nil select the corresponding candidate."
(unwind-protect
(minibuffer-with-setup-hook
#'ivy--minibuffer-setup
- (read-from-minibuffer
- prompt
- initial-input
- ivy-minibuffer-map
- nil
- 'ivy-history))
- (when (eq ivy-exit 'done)
- (pop ivy-history)
- (setq ivy-history
- (cons ivy-text (delete ivy-text ivy-history))))
+ (let ((res (read-from-minibuffer
+ prompt
+ initial-input
+ ivy-minibuffer-map
+ nil
+ 'ivy-history)))
+ (when (eq ivy-exit 'done)
+ (pop ivy-history)
+ (setq ivy-history
+ (cons ivy-text (delete ivy-text ivy-history)))
+ res)))
(remove-hook 'post-command-hook #'ivy--exhibit)))))
(defvar ivy-text ""