branch: externals/ivy-hydra
commit 63691397998e8c86931e1887c9f060a8b595d3b2
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>
ivy.el (ivy--update-history): Behave more like completing-read-default
For `ivy-completing-read'.
* ivy-test.el (ivy-completing-read): Add test.
Fixes #2369
---
ivy-test.el | 13 +++++++++++--
ivy.el | 4 +++-
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/ivy-test.el b/ivy-test.el
index 08ffb6e..182b613 100644
--- a/ivy-test.el
+++ b/ivy-test.el
@@ -31,6 +31,8 @@
(defvar ivy-features nil
"Like `features' but for Ivy testing purposes.")
+(defvar ivy-read-hist nil)
+
(defun ivy-test--record-feature (feature &rest _)
"Record FEATURE in `ivy-features'.
Intended as :after-while advice for `require'."
@@ -188,7 +190,6 @@ Since `execute-kbd-macro' doesn't pick up a let-bound
`default-directory'.")
"one")))
(ert-deftest ivy-read-history ()
- (defvar ivy-read-hist nil)
(should (equal (progn
(setq ivy-read-hist '("c" "b" "a"))
(ivy-with '(ivy-read "test: " '("c" "d") :history
'ivy-read-hist) "RET")
@@ -835,7 +836,15 @@ Since `execute-kbd-macro' doesn't pick up a let-bound
`default-directory'.")
(should (equal (ivy-with '(ivy-completing-read
"Test: " '(("1" . "a") ("2" . "b")))
"RET")
- "1")))
+ "1"))
+ (should (equal (progn
+ (setq ivy-read-hist '("foo"))
+ (ivy-with
+ '(completing-read "test: " '("foo" "bar" "baz") nil t nil
+ 'ivy-read-hist)
+ "fo RET")
+ ivy-read-hist)
+ '("foo"))))
(ert-deftest ivy-completing-read-def-handling ()
;; DEF in COLLECTION
diff --git a/ivy.el b/ivy.el
index b0bd76d..1d48ebf 100644
--- a/ivy.el
+++ b/ivy.el
@@ -2307,7 +2307,8 @@ customizations apply to the current completion session."
(defun ivy--update-history (hist)
(let ((item
- (if (string= ivy-text "")
+ (if (or (string= ivy-text "")
+ (eq (ivy-state-extra-props ivy-last) 'ivy-completing-read))
(ivy-state-current ivy-last)
ivy-text)))
(cond ((equal item ""))
@@ -2605,6 +2606,7 @@ INHERIT-INPUT-METHOD is currently ignored."
:history history
:keymap nil
:dynamic-collection ivy-completing-read-dynamic-collection
+ :extra-props 'ivy-completing-read
:caller (if (and collection (symbolp collection))
collection
this-command))))