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 in-buffer completion does not handle immediate-done well #1178

Closed
sooheon opened this Issue Aug 31, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@sooheon
Contributor

sooheon commented Aug 31, 2017

Having written use-pack I press C-M-i to begin completion.

screen shot 2017-08-31 at 2 22 26 pm

I type age but ivy still does not match use-package

screen shot 2017-08-31 at 2 22 32 pm

Rather than select a completion or quit with C-g (which would make me lose the age that I've typed), I C-M-j (ivy-immediate-done) to just keep what I'd written. But this deletes the prefix to the completion.

screen shot 2017-08-31 at 2 22 39 pm

I think the problem is twofold:

  1. The matcher for in-buffer completion should prioritize exact matches
  2. C-M-j should insert what I've typed but not delete the prefix

@abo-abo abo-abo closed this in acb5f11 Aug 31, 2017

@abo-abo

This comment has been minimized.

Owner

abo-abo commented Aug 31, 2017

Thanks, C-M-j should work now.

I can't do anything about the matcher, as far as I see. The perfect match logic (when the text is exactly one of the candidates, that candidate is selected) won't work here, since your text is package, not use-package. A quick fix is to add $ to your input.

I experimented with one solution, using e.g.

(ivy-read "test: "
          :initial-input "use-")

But then it's not fuzzy anymore without adding a space, e.g. use-age won't match anything (the same thing works properly now).
This isn't a good fix either:

(ivy-read "test: "
          :initial-input "use- ")

Now it's fuzzy, but the perfect match is out the window, and a space will be added by C-M-j.

@sooheon

This comment has been minimized.

Contributor

sooheon commented Sep 1, 2017

Thanks for the $ tip.

Another fix might be to special case the shortest match to always appear at the top. I think definitionally the shortest match to a given query ("age") which also shares the prefix ("use-pack") should be the exact match always, no?

edit: ah, that's not true. I might do "use" [tab] "age", and it it might match use-page over use-package. Still, preferring shorter is good imo. If you want sth longer you can always SPC and type more to disambiguate, but when you've already typed everything and it's still not matching, you have to move to the selection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment