branch: master commit ec1ed07f5788714a523007dc91b9e6c8884bfa1b Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
counsel.el (counsel--find-file-1): Use dired-current-directory for dired Fixes #2274 --- counsel.el | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/counsel.el b/counsel.el index 5ce68ee..a912a29 100644 --- a/counsel.el +++ b/counsel.el @@ -1936,15 +1936,19 @@ The preselect behavior can be customized via user options (file-name-nondirectory buffer-file-name)))) (defun counsel--find-file-1 (prompt initial-input action caller) - (ivy-read prompt #'read-file-name-internal - :matcher #'counsel--find-file-matcher - :initial-input initial-input - :action action - :preselect (counsel--preselect-file) - :require-match 'confirm-after-completion - :history 'file-name-history - :keymap counsel-find-file-map - :caller caller)) + (let ((default-directory + (if (eq major-mode 'dired-mode) + (dired-current-directory) + default-directory))) + (ivy-read prompt #'read-file-name-internal + :matcher #'counsel--find-file-matcher + :initial-input initial-input + :action action + :preselect (counsel--preselect-file) + :require-match 'confirm-after-completion + :history 'file-name-history + :keymap counsel-find-file-map + :caller caller))) ;;;###autoload (defun counsel-find-file (&optional initial-input)