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

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

[elpa] externals/ivy-hydra 864570a 323/395: ivy.el (ivy--get-multi-actio


From: Basil L. Contovounesios
Subject: [elpa] externals/ivy-hydra 864570a 323/395: ivy.el (ivy--get-multi-action): Fix and add a test
Date: Thu, 25 Feb 2021 08:32:30 -0500 (EST)

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

    ivy.el (ivy--get-multi-action): Fix and add a test
    
    Fixes #2598
---
 ivy-test.el | 22 +++++++++++++++++++---
 ivy.el      |  5 +++--
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/ivy-test.el b/ivy-test.el
index 3864cd6..30ae3f7 100644
--- a/ivy-test.el
+++ b/ivy-test.el
@@ -234,19 +234,35 @@ Since `execute-kbd-macro' doesn't pick up a let-bound 
`default-directory'.")
     '(("Key 1" . "Data 1")
       ("Key 2" . "Data 2")))))
 
-(ert-deftest ivy-read-multi-action ()
+(ert-deftest ivy-read-multi-action-1 ()
   (should (equal (let ((res nil))
-                   (ivy-add-actions 'test-ivy-read-multi-action
+                   (ivy-add-actions 'test-ivy-read-multi-action-1
                                     (list (list "a" (lambda (x) (push x res)) 
"action-a")))
                    (ivy-with
                     '(ivy-read "test: " '("x" "y")
                                :action (lambda (x) (message "Default: %s" x))
                                :multi-action (lambda (xs) (message "Default: 
%S" xs))
-                               :caller 'test-ivy-read-multi-action)
+                               :caller 'test-ivy-read-multi-action-1)
                     "M-a M-o a")
                    res)
                  '("y" "x"))))
 
+(ert-deftest ivy-read-multi-action-2 ()
+  (should (equal (let ((res nil))
+                   (ivy-add-actions 'test-ivy-read-multi-action-2
+                                    (list (list "a"
+                                                (lambda (x) (push x res))
+                                                "action-a"
+                                                (lambda (xs) (push xs res)))))
+                   (ivy-with
+                    '(ivy-read "test: " '("x" "y")
+                               :action (lambda (x) (message "Default: %s" x))
+                               :multi-action (lambda (_xs) (message "default"))
+                               :caller 'test-ivy-read-multi-action-2)
+                    "M-a M-o a")
+                   res)
+                 '(("x" "y")))))
+
 (ert-deftest ivy-read-sort-def ()
   (should (equal (ivy-with '(ivy-read "Test: " '("1" "2") :def '("a" "b" "c"))
                            "C-m")
diff --git a/ivy.el b/ivy.el
index b142d79..71f8409 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1336,7 +1336,8 @@ If the input is empty, select the previous history 
element instead."
                (nth 3 (nth (car action) action)))))
     (if multi-action
         multi-action
-      (ivy-state-multi-action state))))
+      (when (eq (car action) 1)
+        (ivy-state-multi-action state)))))
 
 (defun ivy--get-window (state)
   "Get the window from STATE."
@@ -1419,7 +1420,7 @@ See variable `ivy-recursive-restore' for further 
information."
                  cand)))
            ivy-marked-candidates))
          (multi-action (ivy--get-multi-action ivy-last)))
-    (if (and multi-action (eq (car (ivy-state-action ivy-last)) 1))
+    (if multi-action
         (let ((default-directory (ivy-state-directory ivy-last)))
           (funcall multi-action (mapcar #'ivy--call-cand marked-candidates)))
       (dolist (c marked-candidates)



reply via email to

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