branch: master commit 325644728a82a76d45bdf0b1146326fe5d767001 Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
ivy.el (ivy--partial-cd-for-single-directory): Extract And use ivy--re-filter --- ivy.el | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/ivy.el b/ivy.el index 9674168..0499c54 100644 --- a/ivy.el +++ b/ivy.el @@ -1109,6 +1109,16 @@ If the text hasn't changed as a result, forward to `ivy-alt-done'." (substring string (length prefix)) string)) +(defun ivy--partial-cd-for-single-directory () + (when (and + (eq (ivy-state-collection ivy-last) #'read-file-name-internal) + (= 1 (length + (ivy--re-filter + (funcall ivy--regex-function ivy-text) ivy--all-candidates))) + (let ((default-directory ivy--directory)) + (file-directory-p (ivy-state-current ivy-last)))) + (ivy--directory-done))) + (defun ivy-partial () "Complete the minibuffer text as much as possible." (interactive) @@ -1138,13 +1148,7 @@ If the text hasn't changed as a result, forward to `ivy-alt-done'." (concat (mapconcat #'identity parts " ") (and ivy-tab-space (not (= (length ivy--old-cands) 1)) " ")))) - (when (and - (eq (ivy-state-collection ivy-last) #'read-file-name-internal) - (= 1 (length - (ivy--filter ivy-text ivy--all-candidates))) - (let ((default-directory ivy--directory)) - (file-directory-p (ivy-state-current ivy-last)))) - (ivy--directory-done)) + (ivy--partial-cd-for-single-directory) t)))) (defvar ivy-completion-beg nil