Denis Waleev
Denis Waleev

Reputation: 175

Duplicate hints while typing expression in Visual Studio Code

Why do I have the same suggestions while typing expression?

Example:

Typing suggestions

Upvotes: 16

Views: 9204

Answers (4)

darren
darren

Reputation: 5764

I had exactly the same problem. After a week or so, it get really annoying.

basically, as the comments hint to, there are probably multiple linting or intelisense tools. In my case (for python) i had the pylance extension added.

When i disabled this, the problem went away, but features were missing. So i added it back...

For some reason (i dont know why), this fixed the problem !!!

I can only hypothesise that in some way the extension was corrupted. Nevertheless, it worked.

EDIT: I can also confirm that unchecking this setting appears to work:

Jupyter: Pylance Handles Notebooks

My current system is Windows 11, with python 3.10.

enter image description here

Final edit (8 Dec 2022): This is resolved here:

Please could you install VS Code 1.74 and the latest Jupyter, PyLance and Python extension and confirm this still exists.

Upvotes: 20

ds mando
ds mando

Reputation: 21

As of 11/30/22, Jupyter Extension Pre-Release version v2022.11.1003281132 is the latest version fixes this issue. Click the gear icon next to the extension and you should see "install another version..." Then you can select version v2022.11.1003281132.

Upvotes: 2

Ben Saunders
Ben Saunders

Reputation: 1069

TLDR; Installing pre-release version of Jupyter solves (v2022.11...)

Ok, so after some more extensive experimentation I think I found what's causing this in my case. After looking at the processes I noticed that there were two Pylance processes running, and consistently this would only be a problem if I was working in a session with a jupyter notebook open or one that had been opened.

saun89   17740 37.3  0.3 1008004 199492 ?      Sl   20:58   0:22 /home/saun89/.vscode-server-insiders/bin/fef85ea792f6627c83024d1df726ca729d8c9cb3/node /home/saun89/.vscode-server-insiders/extensions/ms-python.vscode-pylance-2022.11.32/dist/server.bundle.js --cancellationReceive=file:9178e897a2b78b36bfd167f79b36c3bdad2931d71b --node-ipc --clientProcessId=17651
saun89   18743  257  0.7 1304584 382288 ?      Sl   20:59   0:20 /home/saun89/.vscode-server-insiders/bin/fef85ea792f6627c83024d1df726ca729d8c9cb3/node /home/saun89/.vscode-server-insiders/extensions/ms-python.vscode-pylance-2022.11.32/dist/server.bundle.js --cancellationReceive=file:8744a321767eed92821fd737be4dc7dcfb728284e5 --node-ipc --clientProcessId=17651

Pylance basically spins up a service for the workspace, and then spins up a separate service for the notebook. Output from "Python Language Server" logs:

enter image description here

Disabling Jupyter removes the duplication, and after installing an earlier version of the extension (v2022.4) this appears to have fully resolved the issue. I'm going to go ahead and log the extension bug once I have something reproducible.

Upvotes: 6

Álvaro González
Álvaro González

Reputation: 146640

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.

Upvotes: 13

Related Questions