Skip to content

Commit

Permalink
Improve ivy--magic-file-slash to not attempt to visit directory we’re…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
sergv committed Mar 24, 2024
1 parent 14c696a commit 94e952e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions ivy.el
Original file line number Diff line number Diff line change
Expand Up @@ -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 "//")))
Expand All @@ -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)
Expand Down

0 comments on commit 94e952e

Please sign in to comment.