Peekmo / atom-autocomplete-php

Autocomplete for PHP in atom editor
MIT License
136 stars 34 forks source link

[FeatureRequest] Sugguest elements which are applicable in current context. #371

Open ghost opened 7 years ago

ghost commented 7 years ago

Autocomplete should either suggest elements which are applicable in current context or should prioritize them.

For examaple:

class Test {
    public function myFunction() {

    }

    sta
}

When you type "sta" it suggest setAttribute!! And static is at 8th number. Is it possible to understand that context is class and only limited things can be defined here (variable/method/comment) so that static comes at top.

Another example is:

class Test {

    pri

    public function myFunction() {

    }
}

While typing "pri" private is at 8th number.

This improvement will help in speeding up selecting the right element from suggestions. Currently either you have to use the mouse or type more characters to highlight the correct element.

Arcesilas commented 6 years ago

I did not verify, but I think Atom uses regex like this to perform search: when searching word, it will search .*w.*o.*r.*d.*

Which is pretty nice when we don't remember exactly the spelling of the word we want, but I agree that sometimes the search is completely dumb.

Typed namespac, and got:

I think it's worth making more than one regex:

  1. ^pattern.*
  2. .*pattern.*
  3. .*p.*a.*t.*t.*e.*r.*n.*

and display results in this order (it means duplicates have to be removed)

But I think it's an Atom issue rather than a package issue, except if the package can perform search its own way.

After a little search, the package responsible for calculating suggestions in Atom is FuzzAldrin