Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ivy-previous-line-or-history doesn't select previous history element #2137

jrosdahl opened this issue Jul 14, 2019 · 1 comment


Copy link

Many thanks for swiper & co!

I've bound C-s/C-r to counsel-grep-or-swiper/counsel-grep-or-swiper-backward (see #2132 for the latter) to mimic the regular isearch-forward/isearch-backward behavior. I've also bound C-r to ivy-previous-line-or-history in ivy-minibuffer-map, symmetrical to C-s in said keymap. C-s C-s then searches forward for the first occurence of the string last sought for. C-r C-r however does not since ivy-previous-line-or-history doesn't insert the previous history element if the input is empty.

It seems like this is caused by the (zerop ivy--index) condition added in abc65d3 (#1137). (Also, this makes ivy-previous-line-or-history asymmetrical to ivy-next-line-or-history since the latter works like documented.) I don’t quite understand the purpose of the fix, so I might miss something, but maybe the solution to purcell/emacs.d#473 could simply be to use ivy-previous-line instead of ivy-previous-line-or-history for <up> in lisp/init-ivy.el? Or, introduce ivy-next-line-or-history-if-at-bottom/ivy-previous-line-or-history-if-at-top commands if the behavior of inserting a history element is wanted only when at bottom/top? @purcell: Any input here?

How to reproduce

  1. (define-key ivy-minibuffer-map (kbd "C-r") 'ivy-previous-line-or-history)
  2. M-x swiper
  3. Enter something that matches a line and press enter
  4. M-x swiper
  5. C-r

Actual behavior

  1. Nothing is inserted in the minibuffer (and the cursor is moved one step up).

Expected behavior

  1. The input from step 3 is inserted in the minibuffer.
jrosdahl added a commit to jrosdahl/swiper that referenced this issue Jul 14, 2019
Fixes abo-abo#2137.

Note also that this reverts the fix in abo-abo#1137.
Copy link

abo-abo commented Jul 15, 2019

Thanks. It seems ivy-previous-line-or-history is out of place now. It used to be bound to C-r for the sole reason of imitating isearch. But now we have C-r bound to ivy-reverse-i-search, which is superior for most commands (even swiper, IMO). Maybe it should be renamed to something like swiper-isearch-repeat-backward.

astoff pushed a commit to astoff/swiper that referenced this issue Jan 1, 2021
Fixes abo-abo#2137
Fixes abo-abo#2138

Note also that this reverts the fix in abo-abo#1137.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging a pull request may close this issue.

2 participants