diff --git a/ivy.el b/ivy.el index c0d2a062..5ddbe64e 100644 --- a/ivy.el +++ b/ivy.el @@ -3268,7 +3268,8 @@ Possible choices are `ivy-magic-slash-non-match-cd-selected', (eolp)) (eq this-command #'ivy-partial-or-done)) (let ((canonical (expand-file-name ivy-text ivy--directory)) - (magic (not (string= ivy-text "/")))) + (magic (not (string= ivy-text "/"))) + dest-dir) (cond ((member ivy-text ivy--all-candidates) (ivy--cd canonical)) ((and (eq system-type 'windows-nt) (string= ivy-text "//"))) @@ -3292,9 +3293,12 @@ Possible choices are `ivy-magic-slash-non-match-cd-selected', (file-directory-p (ivy-state-current ivy-last)) (or (eq ivy-magic-slash-non-match-action 'ivy-magic-slash-non-match-cd-selected) - (eq this-command #'ivy-partial-or-done)))) - (ivy--cd - (expand-file-name (ivy-state-current ivy-last) ivy--directory))) + (eq this-command #'ivy-partial-or-done)) + ;; No point in visiting directory we’re already in. + (not (equal ivy--directory + (setf dest-dir + (expand-file-name (ivy-state-current ivy-last) ivy--directory)))))) + (ivy--cd dest-dir)) ((and (eq ivy-magic-slash-non-match-action 'ivy-magic-slash-non-match-create) magic)