branch: master
commit 28cb79553506c3f01313bc21c66dc33045d3b982
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>
Don't try to call permanent action if there's none
* ivy.el (ivy-next-line-and-call): Update.
(ivy-previous-line-and-call): Update.
Fixes #114.
---
ivy.el | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/ivy.el b/ivy.el
index 8f68bc7..9870032 100644
--- a/ivy.el
+++ b/ivy.el
@@ -416,20 +416,24 @@ If the input is empty, select the previous history
element instead."
(ivy-previous-line arg))
(defun ivy-next-line-and-call (&optional arg)
- "Move cursor vertically down ARG candidates."
+ "Move cursor vertically down ARG candidates.
+Call the permanent action if possible."
(interactive "p")
(ivy-next-line arg)
(ivy--exhibit)
- (with-selected-window (ivy-state-window ivy-last)
- (funcall (ivy-state-action ivy-last))))
+ (when (ivy-state-action ivy-last)
+ (with-selected-window (ivy-state-window ivy-last)
+ (funcall (ivy-state-action ivy-last)))))
(defun ivy-previous-line-and-call (&optional arg)
- "Move cursor vertically down ARG candidates."
+ "Move cursor vertically down ARG candidates.
+Call the permanent action if possible."
(interactive "p")
(ivy-previous-line arg)
(ivy--exhibit)
- (with-selected-window (ivy-state-window ivy-last)
- (funcall (ivy-state-action ivy-last))))
+ (when (ivy-state-action ivy-last)
+ (with-selected-window (ivy-state-window ivy-last)
+ (funcall (ivy-state-action ivy-last)))))
(defun ivy-previous-history-element (arg)
"Forward to `previous-history-element' with ARG."