branch: master commit a986e4ea113162e1f5407b83b6954381499e7d64 Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
ivy.el (ivy--yank-handle-case-fold): Add Fixes #2194 --- ivy-test.el | 10 ++++++++++ ivy.el | 11 ++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/ivy-test.el b/ivy-test.el index 0989abd..a6fb301 100644 --- a/ivy-test.el +++ b/ivy-test.el @@ -1368,6 +1368,16 @@ a buffer visiting a file." (should (string= (ivy-with read-numbers "C-' a") "1")) (should (string= (ivy-with read-numbers "C-v C-' d") "7"))))) +(ert-deftest ivy--yank-handle-case-fold () + (should (string= + (let ((ivy-text "")) + (ivy--yank-handle-case-fold "FirstName")) + "FirstName")) + (should (string= + (let ((ivy-text "f")) + (ivy--yank-handle-case-fold "irstName")) + "irstname"))) + (provide 'ivy-test) ;;; ivy-test.el ends here diff --git a/ivy.el b/ivy.el index 5a33d6f..983b87a 100644 --- a/ivy.el +++ b/ivy.el @@ -4302,6 +4302,12 @@ Skip buffers that match `ivy-ignore-buffers'." :keymap ivy-switch-buffer-map :caller 'ivy-switch-buffer-other-window)) +(defun ivy--yank-handle-case-fold (text) + (if (and (> (length ivy-text) 0) + (string= (downcase ivy-text) ivy-text)) + (downcase text) + text)) + (defun ivy--yank-by (fn &rest args) "Pull buffer text from current line into search string. The region to extract is determined by the respective values of @@ -4320,7 +4326,10 @@ point before and after applying FN to ARGS." (unless text (goto-char beg))))) (when text - (insert (replace-regexp-in-string " +" " " text t t))))) + (insert (replace-regexp-in-string + " +" " " + (ivy--yank-handle-case-fold text) + t t))))) (defun ivy-yank-word (&optional arg) "Pull next word from buffer into search string.