jcs-elpa / company-fuzzy

Fuzzy matching for `company-mode'
GNU General Public License v3.0
120 stars 9 forks source link

company-diag is obscured when using company-fuzzy #15

Closed IgorGee closed 3 years ago

IgorGee commented 3 years ago

When using company-fuzzy, it seems to remove a lot of valuable information in company-diag.

image

When debugging, it's useful to know which backends are enabled. Here is what it looks like without company-fuzzy:

image

It would be nice to maintain the functionality of company-diag while still using company-fuzzy

jcs090218 commented 3 years ago

Hi, may I ask where could you find company-diag? I could not find it either on MELPA or ELPA. Can you post me a link to that package so I could further investigate the issue.

IgorGee commented 3 years ago

company-diag is a command that is part of company itself:

https://github.com/company-mode/company-mode/blob/master/company.el#L2653

jcs090218 commented 3 years ago

@dgutov Sorry to ping you here.

I have read through the code from company-diag but not quite sure why this package doesn't provide information to company-diag. Any clue with this behaviour? 😕

The logic behinds this tool is to combine all backends to one backend then do the fuzzy scoring. That's about it! Not sure why this wouldn't work with company-diag? Am I missing some important command from the backend?

dgutov commented 3 years ago

@jcs090218 What is unexpected here?

company-diag examines and prints the current value of company-backends. Which company-fuzzy--enable sets to its own value, a list with single element: the wrapper backend. company-diag has no idea about the variable company-fuzzy--backends, so it doesn't print its value.

jcs090218 commented 3 years ago

I was expecting to see the result from backend company-fuzzy-all-other-backends?

I assumed company-diag would know company-backends but why not printing the only backend company-fuzzy-all-other-backends? 😕 For example,

capf (company-diag)

...
Completions:
   "capf1"
   "capf2"

keywords (company-diag)

...
Completions:
   "keyword1"
   "keyword2"

If company-fuzzy is enabled,

company-fuzzy-all-other-backends (company-diag)

...
Completions:
   "capf1"
   "capf2"
   "keyword1"
   "keyword2"

I would expect to see all of them in a list?

dgutov commented 3 years ago

Yep. I would expect to see it there too.

I guess something in the implementation depends on some context info, maybe private vars or not well-defined behavior.

This is your code, right? I recommend some edebug-ing. Instrument company-fuzzy-all-candidates, then evaluate

  (let ((company-backend 'company-fuzzy-all-other-backends)) (company-call-backend 'candidates "def-"))

The above is the form that company-diag uses. See why your function returns nil. Since it's called in the original buffer, I would expect all the local vars, etc, still have the necessary values.

jcs090218 commented 3 years ago

Okay, I miss used the command candidates in function company-fuzzy-all-candidates. It always return nil, not sure why I did that in the first place. 😕

Now it should be fixed in 7140e63325bea502959e853512d7c78588de8c9c.

dgutov commented 3 years ago

Surely it didn't always return nil? If it did that, the backend would never have worked in the first place.

jcs090218 commented 3 years ago

Surely it didn't always return nil? If it did that, the backend would never have worked in the first place.

I had injected candidates right in front of the sorting function. :P

https://github.com/jcs-elpa/company-fuzzy/blob/5220761afcaae039b6ec6f75005371888623674d/company-fuzzy.el#L356

I don't remember why I did that though..

dgutov commented 3 years ago

Erm.

That would do it. :man_shrugging: