Skip to content

ivy-use-selectable-prompt doesn't work when a dynamic collection is empty #1183

Description

@Stebalien

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.

Activity

  1. fabacino commented on Oct 31, 2017

    @fabacino
    Contributor

    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.

  2. added a commit that references this issue on Oct 31, 2017
    55d1898
  3. reopened this on Nov 1, 2017
  4. abo-abo commented on Nov 1, 2017

    @abo-abo
    Owner

    @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.

  5. added a commit that references this issue on Nov 2, 2017
    b7f2700
  6. fabacino commented on Nov 2, 2017

    @fabacino
    Contributor

    @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.

  7. abo-abo commented on Nov 2, 2017

    @abo-abo
    Owner

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions