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

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

[elpa] externals/ivy-hydra 6f50fca 286/395: ivy.el: When reading file na


From: Basil L. Contovounesios
Subject: [elpa] externals/ivy-hydra 6f50fca 286/395: ivy.el: When reading file names, take the non-directory part of :initial-input
Date: Thu, 25 Feb 2021 08:32:21 -0500 (EST)

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

    ivy.el: When reading file names, take the non-directory part of 
:initial-input
    
    * ivy-test.el (ivy-read-file-name-initial-input): Add test
    
    Fixes #1632
---
 ivy-test.el | 20 ++++++++++++++++++++
 ivy.el      |  4 +---
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/ivy-test.el b/ivy-test.el
index fd0b463..3d1a5cb 100644
--- a/ivy-test.el
+++ b/ivy-test.el
@@ -1065,6 +1065,26 @@ Since `execute-kbd-macro' doesn't pick up a let-bound 
`default-directory'.")
            "DEL C-M-j"
            :dir "/tmp"))))
 
+(ert-deftest ivy-read-file-name-initial-input ()
+  (let ((fname (expand-file-name "ivy.el")))
+    (should (string=
+             fname
+             (ivy-with
+              `(ivy-read "Find file: " 'read-file-name-internal
+                         :predicate 'file-exists-p
+                         :require-match 'confirm-after-completion
+                         :initial-input ,fname
+                         :preselect ,fname
+                         :def ,fname
+                         :history 'file-name-history
+                         :keymap nil
+                         :sort t
+                         :dynamic-collection nil
+                         :caller 'read-file-name-internal
+                         :action (lambda (x) x))
+              "RET"))))
+  (should (string= (ivy-state-initial-input ivy-last) "ivy.el")))
+
 (ert-deftest ivy-counsel-read-directory-name ()
   (should
    (equal (expand-file-name "/tmp/")
diff --git a/ivy.el b/ivy.el
index 08c93d4..d591e8e 100644
--- a/ivy.el
+++ b/ivy.el
@@ -2485,9 +2485,7 @@ This is useful for recursive `ivy-read'."
                            (equal initial-input default-directory)
                            (equal initial-input ""))
                  (setq coll (cons initial-input coll)))
-               (when (or (not (ivy-state-action ivy-last))
-                         (equal (ivy--get-action ivy-last) #'identity))
-                 (setq initial-input nil))))
+               (setq initial-input (file-name-nondirectory initial-input))))
             ((eq collection #'internal-complete-buffer)
              (setq coll (ivy--buffer-list
                          ""



reply via email to

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