emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/ivy-hydra 16d391d 263/395: ivy.el (ivy--done): Handle i


From: Basil L. Contovounesios
Subject: [elpa] externals/ivy-hydra 16d391d 263/395: ivy.el (ivy--done): Handle ivy-text being a full path when on remote
Date: Thu, 25 Feb 2021 08:32:16 -0500 (EST)

branch: externals/ivy-hydra
commit 16d391dfbff55109d7c0f4b59839336977d51046
Author: Oleh Krehel <ohwoeowho@gmail.com>
Commit: Oleh Krehel <ohwoeowho@gmail.com>

    ivy.el (ivy--done): Handle ivy-text being a full path when on remote
    
    Suppose we are on "/ssh:dev:/bin", and `ivy-text' is yanked
    "/etc/hosts". Then "RET" or "C-j" should select "/ssh:dev:/etc/hosts".
    
    * ivy-test.el (ivy--handle-full-path-yank-on-remote): Add test.
---
 ivy-test.el |  7 +++++++
 ivy.el      | 17 +++++++++++++----
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/ivy-test.el b/ivy-test.el
index 7af21c1..599f840 100644
--- a/ivy-test.el
+++ b/ivy-test.el
@@ -1510,6 +1510,13 @@ a buffer visiting a file."
                      (ivy--handle-directory "/sudo::"))
                    "/sudo::/tmp/")))
 
+(ert-deftest ivy--handle-full-path-yank-on-remote ()
+  (should
+   (string=
+    (let ((ivy--directory "/ssh:dev:/bin/"))
+      (ivy--expand-file-name "/etc/hosts"))
+    "/ssh:dev:/etc/hosts")))
+
 (ert-deftest ivy-inhibit-action ()
   (should (equal (ivy-with
                   '(let ((ivy-inhibit-action #'identity))
diff --git a/ivy.el b/ivy.el
index e092118..bbddc8d 100644
--- a/ivy.el
+++ b/ivy.el
@@ -730,6 +730,18 @@ N is obtained from `ivy-more-chars-alist'."
   `(with-selected-window (ivy--get-window ivy-last)
      ,@body))
 
+(defun ivy--expand-file-name (text)
+  (cond
+    ((eq (ivy-state-history ivy-last) 'grep-files-history)
+     text)
+    (ivy--directory
+     (if (and (string-match-p "^/" text) (file-remote-p ivy--directory))
+         (let ((parts (split-string ivy--directory ":")))
+           (concat (nth 0 parts) ":" (nth 1 parts) ":" text))
+       (expand-file-name text ivy--directory)))
+    (t
+     text)))
+
 (defun ivy--done (text)
   "Insert TEXT and exit minibuffer."
   (if (member (ivy-state-prompt ivy-last) '("Create directory: " "Make 
directory: "))
@@ -737,10 +749,7 @@ N is obtained from `ivy-more-chars-alist'."
     (when (stringp text)
       (insert
        (setf (ivy-state-current ivy-last)
-             (if (and ivy--directory
-                      (not (eq (ivy-state-history ivy-last) 
'grep-files-history)))
-                 (expand-file-name text ivy--directory)
-               text))))
+             (ivy--expand-file-name text))))
     (setq ivy-exit 'done)
     (exit-minibuffer)))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]