13

Why do I have the same suggestions while typing expression?

Example:

Typing suggestions

matronator
  • 465
  • 6
  • 13
Denis Waleev
  • 145
  • 2
  • 8

4 Answers4

17

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.

D.L
  • 4,339
  • 5
  • 22
  • 45
  • Weird, same behavior on my side. Disabling `pylance` and enabling it back solved the issue. – max0r Sep 02 '22 at 08:37
  • Thanks for this, was driving me nuts but disabling/reenabling `pylance` solved for me as well! – Ben Saunders Nov 16 '22 at 02:15
  • 1
    for what its worth, the problem sometimes comes back. I notice it first with Jupyter notebooks in vs code.... i dont cannot confirm if they are related. only an observation. – D.L Nov 16 '22 at 13:49
  • Same here in terms of the recurring nature :(, I'll see if I can isolate a competing extension – Ben Saunders Nov 28 '22 at 20:53
12

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.

kelsny
  • 23,009
  • 3
  • 19
  • 48
Álvaro González
  • 142,137
  • 41
  • 261
  • 360
  • I just tried to disable all extensions, and there is only one suggestion and no duplicates. But I want to use PHP Intelephense extension. So I think, is there way to remove suggestions from VS Code or PHP Intelephense only? – Denis Waleev Sep 12 '18 at 06:55
  • You want to use PHP Intelephense but not its suggestions? You'd need to check the extension documentation but I don't think that's possible. It's also a strange request: you'll also get dupes elsewhere ("Go to Symbol", "Peek Definition", etc.). What exactly are you trying to accomplish? – Álvaro González Sep 12 '18 at 07:58
  • I just want to know what other php developers do with this thing. Nothing? – Denis Waleev Sep 12 '18 at 08:46
  • I can't speak for others but I just use only one extension that provides a given feature. When there're several available, I evaluate them one by one, starting with the most downloaded one and maybe skipping those that look too unpolished. – Álvaro González Sep 12 '18 at 08:54
  • In this case, you have suggestions from VS Code and other extension, that duplicates these suggestions, right? I'm using only one too. But suggestions duplicate yet. – Denis Waleev Sep 12 '18 at 09:03
  • I'm really getting lost in the sea of comments. I've updated my answer with further hints. If that's still not what you're asking, please edit the question altogether and try to be more specific. – Álvaro González Sep 12 '18 at 09:22
  • Thank you, this addition is exactly what I need! – Denis Waleev Sep 12 '18 at 09:27
6

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.

Ben Saunders
  • 929
  • 10
  • 20
2

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.

ds mando
  • 21
  • 2