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: do *not* fix :preselect getting deselected with new input #1563

Closed
raxod502 opened this issue May 11, 2018 · 5 comments
Closed

Ivy: do *not* fix :preselect getting deselected with new input #1563

raxod502 opened this issue May 11, 2018 · 5 comments

Comments

@raxod502
Copy link
Contributor

@raxod502 raxod502 commented May 11, 2018

I noticed the recent commit 4fef67f. Actually, I would like the contrary behavior: when any key is typed, the selection should be moved to the first candidate, disregarding the preselected candidate (if any). Is there a way I can achieve this behavior?

@abo-abo
Copy link
Owner

@abo-abo abo-abo commented May 12, 2018

The recent commit fixed a clearly not intended behavior of the index remaining at 1 (zero-based) while sliding to non-:preselect on input.

Your intended behavior should be there, related to ivy-index-functions-alist and ivy-recompute-index-zero. Further investigation is necessary on why it doesn't work currently.

@raxod502
Copy link
Contributor Author

@raxod502 raxod502 commented May 12, 2018

Yes, I noticed that the faulty behavior is a bit hard to reproduce (though it is consistent with a given test case).

Example test case, click to expand

For example, with some nonstandard settings enabled, I ran C-h f with point on the symbol regexp-quote. This caused Ivy to preselect that candidate in the menu:

image

I would now expect that if I type a character, my selection moves back to the beginning of the list. That doesn't happen:

image

But if I type a second character, it does:

image

And most puzzling of all, if I delete the second character, then my selection is back at the beginning as it should have been in the first place:

image

If I delete the first character, then I'm back at the preselected candidate, and can repeat the process as desired:

image

If you don't see the behavior in your own configuration, then I can see about getting a test case that starts from emacs -Q.

@raxod502
Copy link
Contributor Author

@raxod502 raxod502 commented May 15, 2018

@abo-abo Actually, this is very easy to reproduce. Simply activate counsel-mode from the latest version of this repository (be6db35), place point at the end of regexp-quote, run C-h f, and then type r (this changes the input from ^ to ^r). Then the menu changes from:

image

to:

image

whereas I would like it to return me to the beginning of the menu, like this:

image

@raxod502
Copy link
Contributor Author

@raxod502 raxod502 commented May 15, 2018

@abo-abo The code which causes this behavior is:

swiper/ivy.el

Lines 3066 to 3072 in be6db35

(and (not (string= name ""))
(not (and ivy--flx-featurep
(eq ivy--regex-function 'ivy--regex-fuzzy)
(< (length cands) 200)))
ivy--old-cands
(cl-position (ivy-state-current ivy-last) cands
:test #'equal))

The code allows for the index to be maintained if the previously selected candidate is still available in the list. That would make sense for a manually selected candidate, but perhaps a case needs to be added there so that the logic is not triggered in the case of a preselected candidate.

@raxod502
Copy link
Contributor Author

@raxod502 raxod502 commented May 15, 2018

Created #1573.

@abo-abo abo-abo closed this in 0cf0e6d Jul 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants