Search code examples
visual-studio-codeautosuggestcode-hinting

Duplicate hints while typing expression in Visual Studio Code


Why do I have the same suggestions while typing expression?

Example:

Typing suggestions


Solution

  • Visual Studio Code provides an API so third-party extensions and built-in modules can contribute suggestions for auto-completion pop-ups. The system is currently designed so suggestions are merely appended—there's no duplicate detection or removal (perhaps because extensions can also take care of sorting suggestions and such algorithm would get on the way). That means that if you have more than one extension or module for a given language you can easily get duplicate entries.

    Having several extensions for PHP is not necessarily a bad idea since they can address different needs (for instance, PHP DocBlocker just creates annotations, it doesn't provide auto-completion suggestions) but you have at least two extensions (PHP Intelephense and PHP Intellisense) that do exactly the same things. That's likely to hurt performance (all your workspace files will be scanned several times) and just adds noise.

    I suggest you read the extension descriptions carefully to learn what they do exactly and then figure out which ones you need. Remember that extensions can be enabled/disabled in a per-workspace basis.


    The following is just my own totally subjective opinion. Among the PHP extensions that provide code intelligence only two of them seem mature enough:

    • PHP Intelephense
    • PHP Intellisense

    I've tried both. PHP Intelephense works best for me than PHP Intellisense so that's the one I've kept. I've also disabled php.suggest.basic following the installation instructions because basic suggestions didn't add any value to me (they were blind string matching):

    Turn off the php.suggest.basic setting for best results.

    ... as well as taming builtin Emmet support, which was providing really dumb suggestions:

    "emmet.showExpandedAbbreviation": "inMarkupAndStylesheetFilesOnly"
    

    YMMV.