Skip to content

Commit 7542a56

Browse files
committed
Improve ivy--magic-file-slash to not attempt to visit directory we’re already in
I found an issue where current directory is being visited repeatedly on pressing / without doing any progress. It was an empty directory and I wanted to get literal ‘/’ inserted. In any case visiting the directory we’re already in serves no purpose.
1 parent 595d442 commit 7542a56

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

ivy.el

+8-4
Original file line numberDiff line numberDiff line change
@@ -3245,7 +3245,8 @@ Possible choices are `ivy-magic-slash-non-match-cd-selected',
32453245
(eolp))
32463246
(eq this-command #'ivy-partial-or-done))
32473247
(let ((canonical (expand-file-name ivy-text ivy--directory))
3248-
(magic (not (string= ivy-text "/"))))
3248+
(magic (not (string= ivy-text "/")))
3249+
dest-dir)
32493250
(cond ((member ivy-text ivy--all-candidates)
32503251
(ivy--cd canonical))
32513252
((and (eq system-type 'windows-nt) (string= ivy-text "//")))
@@ -3269,9 +3270,12 @@ Possible choices are `ivy-magic-slash-non-match-cd-selected',
32693270
(file-directory-p (ivy-state-current ivy-last))
32703271
(or (eq ivy-magic-slash-non-match-action
32713272
'ivy-magic-slash-non-match-cd-selected)
3272-
(eq this-command #'ivy-partial-or-done))))
3273-
(ivy--cd
3274-
(expand-file-name (ivy-state-current ivy-last) ivy--directory)))
3273+
(eq this-command #'ivy-partial-or-done))
3274+
;; No point in visiting directory we’re already in.
3275+
(not (equal ivy--directory
3276+
(setf dest-dir
3277+
(expand-file-name (ivy-state-current ivy-last) ivy--directory))))))
3278+
(ivy--cd dest-dir))
32753279
((and (eq ivy-magic-slash-non-match-action
32763280
'ivy-magic-slash-non-match-create)
32773281
magic)

0 commit comments

Comments
 (0)