branch: externals/ivy-hydra
commit d1c3613fbaeb7ce44de2ace39982a44bf4436c6b
Author: Steve Purcell <[email protected]>
Commit: GitHub <[email protected]>

    Fix ivy-{next,previous}-line-or-history when input is empty
    
    Without any input, the previous versions would immediately start navigating 
history instead of the candidates.
---
 ivy.el | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/ivy.el b/ivy.el
index 0f464f1..ed9899e 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1349,9 +1349,10 @@ If the text hasn't changed as a result, forward to 
`ivy-alt-done'."
   "Move cursor vertically down ARG candidates.
 If the input is empty, select the previous history element instead."
   (interactive "p")
-  (if (string= ivy-text "")
-      (ivy-previous-history-element 1)
-    (ivy-next-line arg)))
+  (let ((orig-index ivy--index))
+    (ivy-next-line arg)
+    (when (and (string= ivy-text "") (eq ivy--index orig-index))
+      (ivy-previous-history-element 1))))
 
 (defun ivy-previous-line (&optional arg)
   "Move cursor vertically up ARG candidates."
@@ -1369,9 +1370,10 @@ If the input is empty, select the previous history 
element instead."
   "Move cursor vertically up ARG candidates.
 If the input is empty, select the previous history element instead."
   (interactive "p")
-  (when (string= ivy-text "")
-    (ivy-previous-history-element 1))
-  (ivy-previous-line arg))
+  (let ((orig-index ivy--index))
+    (ivy-previous-line arg)
+    (when (and (string= ivy-text "") (eq ivy--index orig-index))
+      (ivy-previous-history-element 1))))
 
 (defun ivy-toggle-calling ()
   "Flip `ivy-calling'."

Reply via email to