branch: master
commit 2d7f2879efe4ec39037c3ac0f1e68987e975013e
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>
Improve "TAB" interaction with `confirm-nonexistent-file-or-buffer'
* ivy.el (ivy-partial-or-done): When
`confirm-nonexistent-file-or-buffer' is t, and there are no
candidates, modify the prompt to "(confirm)" right after the first
"TAB".
Re #76
---
ivy.el | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/ivy.el b/ivy.el
index fb1b74c..7838ab3 100644
--- a/ivy.el
+++ b/ivy.el
@@ -280,11 +280,17 @@ candidate."
(new (try-completion postfix
(mapcar (lambda (str) (substring str
(string-match postfix str)))
ivy--old-cands))))
- (when new
- (delete-region (minibuffer-prompt-end) (point-max))
- (setcar (last parts) new)
- (insert (mapconcat #'identity parts " ")
- (if ivy-tab-space " " ""))))))
+ (if new
+ (progn
+ (delete-region (minibuffer-prompt-end) (point-max))
+ (setcar (last parts) new)
+ (insert (mapconcat #'identity parts " ")
+ (if ivy-tab-space " " "")))
+ (when (and (eq confirm-nonexistent-file-or-buffer t)
+ (memq (ivy-state-collection ivy-last)
+ '(read-file-name-internal
+ internal-complete-buffer)))
+ (ivy-done))))))
(defun ivy-immediate-done ()
"Exit the minibuffer with the current input."