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
Company-capf calls the completion table with 'metadata action for each candidate #1351
Comments
This was added in 390d9af. We do need every item's annotations to remove duplicates. And so far we haven't been caching the annotation function. @monnier Is it expected that the metadata can be costly to fetch? IIUC the issue was that the completion table re-calculated the set of completion for every operation, metadata or not. So adding the caching looks like an all-around good idea. |
Yes, the caching done in patch installed for bug#59678 is a good thing regardless of this here issue. |
I suppose we could try to cache it per-string per-completion (since it might conceivably differ for different prefixes). |
Thanks for the information. After some debugging, I think I get it now: In However, in this case, the result completion table does include a lots of duplicated candidates. The completion table is calculated from So overall IMO this is not a bug in company-mode. The issue on sh-mode is fixed by the patch in bug#59678 and this behavior should not affect other modes. |
I would close this issue then. Thanks for all your help. |
In `company--strip-duplicates` function, it would only compare items'
annotation when the name of the items are equal. So in normal circumstances
it should not call 'metadata action if there are no duplicates.
But `metadata` doesn't give you annotations. It gives you a function
which can then give you the annotation. You're supposed to call
`metadata` *once* and then use the annotation function N times to retrieve the
N annotations you need.
Stefan
|
But |
Ah, never mind. |
I've added the cache for capf-metadata. Please test for any breakage, when you have time. |
In the discussion of emacs bug #59678, Stefan mentioned that
So I want to create an issue here to report this possibly unexpected behavior.
Output of the command
M-x company-diag
Describe the issue
Company-capf would call the capf function with 'metadata action for each candidate, which makes some modes pretty slow on completing. (The above bug report contains a patch to fix one such issue for sh-mode though.)
Steps to reproduce
In the above sh-mode example (before applying that patch), adding a log in
sh--cmd-completion-table
can verify the behavior.Expected behavior
I'm not sure. Maybe company-mode should cache the completion table? Or should it only call 'metadata action for visible candidates?
The text was updated successfully, but these errors were encountered: