Skip to content

Commit

Permalink
ivy.el (ivy--call-marked): Don't call multi-action if non-default act…
Browse files Browse the repository at this point in the history
…ion was chosen

Instead, call the chosen non-default action on each candidate.

* ivy-test.el (ivy-read-multi-action): Add test.

Fixes abo-abo#2598
  • Loading branch information
abo-abo committed Jun 8, 2020
1 parent 8783d92 commit b2af619
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions ivy-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion ivy.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b2af619

Please sign in to comment.