swiper icon indicating copy to clipboard operation
swiper copied to clipboard

Fix for issue #2805 by using company-finish on counsel-company.

Open joefbkohler opened this issue 4 years ago • 2 comments

Simple change that makes counsel-company work more seamlessly with company-complete. By using company-finish instead of ivy-completion-in-region-action many behaviors expected from company, like 'keep-prefix' option and post-complete hooks now work.

This change needs that company-abort be called only if ivy-exit is nil when unwinding, otherwise company-finish does not work.

joefbkohler avatar Mar 28 '21 06:03 joefbkohler

Hi, a few comments here if you don't mind.

  1. I don't think we still need the variable len if we are not bothering with ivy-completion-in-region-action. We also don't need to set ivy-completion-{beg,end}.

  2. We could wrap the ivy-read part with (when company-candidates ...) so that it does nothing when there is no candidate, replicating the behavior of company-complete.

  3. I suspect that the workaround is not needed. The problem is that we are dealing with outdated company-candidates because company-complete-common inserted the common part without updating the variables. In fact, I think we could just call company-abort and then company-complete before calling ivy-read so that the variables are properly set. It also solves the problem that the text properties of the candidates are incorrect (the completed common part is not properly propertized).

usaoc avatar Mar 30 '21 00:03 usaoc

I am also touching this, and I think my changes could be integrated into this PR:

https://github.com/abo-abo/swiper/pull/2849

NightMachinery avatar Apr 15 '21 13:04 NightMachinery