branch: externals/ivy-hydra
commit 388e0d415f013cea48d92d1ac0cfd73ddbab173f
Author: Ha Le <[email protected]>
Commit: Oleh Krehel <[email protected]>
ivy.el (ivy--magic-tilde-directory): Fix for non-standard home path
Fixes #2316
Fixes #2319
---
ivy.el | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/ivy.el b/ivy.el
index a7788a8..1a02aa3 100644
--- a/ivy.el
+++ b/ivy.el
@@ -3200,14 +3200,14 @@ Should be run via minibuffer `post-command-hook'."
(defun ivy--magic-tilde-directory (dir)
"Return an appropriate home for DIR for when ~ or ~/ are entered."
- (expand-file-name
- (let (remote)
- (if (and (setq remote (file-remote-p dir))
- (let ((local (file-local-name dir)))
- (not (or (string= "/root/" local)
- (string-match-p "/home/\\([^/]+\\)/\\'" local)))))
- (concat remote "~/")
- "~/"))))
+ (file-name-as-directory
+ (expand-file-name
+ (let* ((home (expand-file-name (concat (file-remote-p dir) "~/")))
+ (dir-path (file-local-name dir))
+ (home-path (file-local-name home)))
+ (if (string= dir-path home-path)
+ "~"
+ home)))))
(defun ivy-update-candidates (cands)
(ivy--insert-minibuffer