branch: externals/ivy-hydra
commit b2af61949a82046963e2f2bad3886f7375290ea3
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>
ivy.el (ivy--call-marked): Don't call multi-action if non-default action
was chosen
Instead, call the chosen non-default action on each candidate.
* ivy-test.el (ivy-read-multi-action): Add test.
Fixes #2598
---
ivy-test.el | 13 +++++++++++++
ivy.el | 2 +-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/ivy-test.el b/ivy-test.el
index f79504e..3864cd6 100644
--- a/ivy-test.el
+++ b/ivy-test.el
@@ -234,6 +234,19 @@ 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 ()
+ (should (equal (let ((res nil))
+ (ivy-add-actions 'test-ivy-read-multi-action
+ (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)
+ "M-a M-o a")
+ res)
+ '("y" "x"))))
+
(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 7444bfc..b142d79 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1419,7 +1419,7 @@ See variable `ivy-recursive-restore' for further
information."
cand)))
ivy-marked-candidates))
(multi-action (ivy--get-multi-action ivy-last)))
- (if multi-action
+ (if (and multi-action (eq (car (ivy-state-action ivy-last)) 1))
(let ((default-directory (ivy-state-directory ivy-last)))
(funcall multi-action (mapcar #'ivy--call-cand marked-candidates)))
(dolist (c marked-candidates)