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

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

[elpa] master 5826c86 035/348: ivy.el (ivy--reset-state): Add workaround


From: Oleh Krehel
Subject: [elpa] master 5826c86 035/348: ivy.el (ivy--reset-state): Add workaround for dired-do-copy
Date: Sat, 8 Apr 2017 11:03:18 -0400 (EDT)

branch: master
commit 5826c869ca0c745d502f77eb9cc499d7d00a3025
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    ivy.el (ivy--reset-state): Add workaround for dired-do-copy
    
    Example scenario: `dired-dwim-target' is t, and a file "foo" is copied
    from directory-1 to directory-2. But directory-2 already has a file
    "foobar".
    
    Passed to ivy, :initial-input is "directory-2" and :preselect is
    "directory-2/foo". Without the workaround, the :preselect will choose
    "foobar" when "RET" is pressed. So the only correct way to make a file
    copy and not a file overwrite would be "foo C-M-j" - much longer than
    the indented "RET".
    
    With the workaround, the preselect is disabled, resulting in "./" being
    selected with "RET".
---
 ivy.el | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/ivy.el b/ivy.el
index 0931ada..d693a06 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1455,6 +1455,9 @@ This is useful for recursive `ivy-read'."
                       (not (equal initial-input ""))
                       (file-directory-p initial-input))
                  (progn
+                   (when (and (eq this-command 'dired-do-copy)
+                              (equal (file-name-nondirectory initial-input) 
""))
+                     (setf (ivy-state-preselect state) (setq preselect nil)))
                    (setq ivy--directory initial-input)
                    (setq initial-input nil)
                    (when preselect



reply via email to

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