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-use-selectable-prompt doesn't work when a dynamic collection is empty #1183

Closed
Stebalien opened this issue Sep 6, 2017 · 4 comments
Closed

Comments

@Stebalien
Copy link
Contributor

@Stebalien Stebalien commented Sep 6, 2017

When a dynamic collection is empty, one can't select the input field by enabling ivy-use-selectable-prompt.

Also, pressing RET calls the action on the last highlighted item (the item that was being highlighted just before the dynamic collection function returned an empty collection). This is probably related so I figured I'd note it.

@fabacino
Copy link
Contributor

@fabacino fabacino commented Oct 31, 2017

Could reproduce the issue with

(ivy-read "choose: "
          '(lambda (x)
             (if (> (length x) 2)
                 '()
               '("a" "b" "c")))
          :dynamic-collection t)

I will take a look at it.

fabacino added a commit to fabacino/swiper that referenced this issue Oct 31, 2017
Previously, the minibuffer prompt was not refreshed in case a dynamic
collection returned no candidates. This triggered the following
problems:

- Candidates were displayed even though they did not match the filter.
- The prompt was not selectable.

Fixes abo-abo#1183
@abo-abo abo-abo reopened this Nov 1, 2017
@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Nov 1, 2017

@fabacino Sorry, I have to revert your commit: it breaks the smooth redisplay for :dynamic-collection. The minibuffer is blinking rapidly as the user types. We'll have to figure out how to fix this.

abo-abo added a commit that referenced this issue Nov 1, 2017
…didates"

This reverts commit 55d1898.

Re #1183
fabacino added a commit to fabacino/swiper that referenced this issue Nov 2, 2017
Previously, the minibuffer prompt was not refreshed in case a dynamic
collection returned no candidates.
For async commands this makes sense as `nil` could be interpreted both
as the empty list, meaning no candidates found, or as a sign that the
process is still running.
For sync functions however, it is clear that `nil` stands for no
candidates found and thus the minibuffer should be refreshed. This
should fix the following problems:

- Candidates were displayed even though they did not match the filter.
- The prompt was not selectable.

Fixes abo-abo#1183
@fabacino
Copy link
Contributor

@fabacino fabacino commented Nov 2, 2017

@abo-abo Thanks for your feedback. I think the problem is that a value of nil for ivy--all-candidates can mean two different things:

  1. The function (sync or async) has returned no candidates.
  2. We don't know the candidates yet, because an async function is still running.

I made a new fix, basically checking if there is a running counsel process. If there is, an async function is still running and we don't refresh the minibuffer. If there is none, however, we can safely assume that the function has returned an empty set of candidates. In that case, we update the minibuffer.

fabacino@b7f2700

If you like it, I can PR. The hard-coded process name is not pretty, but there are other references to the counsel package within ivy.el, so I figured it is probably ok.

@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Nov 2, 2017

If you like it, I can PR. The hard-coded process name is not pretty, but there are other references to the counsel package within ivy.el, so I figured it is probably ok.

Sounds good, please PR. We can refactor the hard-coded stuff later if there's a need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.