Skip to content

Preselected value gets added to candidates #1017

@fabacino

Description

@fabacino

In ivy--reset-state there is some code which adds the value specified through :preselect to the collection if it is not already in there. I first thought this is a bug but apparently it looks like a feature. Unfortunately I have yet to find out what this is useful for. As the custom input can be something completely different than the candidates, it looks quite weird to me. Not specifing a preselect value for ivy-read is not enough, as the custom input is passed as preselect anyway as soon as ivy-resume is called.

Example:

  1. M-x counsel-apropos RET
  2. Type counsel org goto
  3. C-M-j
  4. C-c C-r (or your equivalent for ivy-resume)
  5. counsel org goto got added to the top of the list and can be selected like a normal candidate despite being custom input. As the action dinstinguishes between custom input and selected candidates it will not do the right thing for the custom entry turned candidate.

The problem with the action can probably be circumvented by adding an additional check whether the input is part of the collection, so no big deal there. But still I think it looks off to have an entry in the list which is completely different than the others., e.g. a regexp among a list of symbols.

I would appreciate if somebody could explain the use cases of this feature to me. Thank you.

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