Duplicate hints while typing expression in Visual Studio Code
Asked Answered
C

4

16

Why do I have the same suggestions while typing expression?

Example:

Typing suggestions

Chubb answered 11/9, 2018 at 12:15 Comment(7)
are you using the All autocomplete extensionJalapa
No, I'm not using this extensionChubb
What extensions are you using?Stereoisomerism
That suggests you have three extensions for the same language enabled at the same time.Margarito
@AlexMyers, For PHP I'm using 6 extensions: PHP DocBlocker, PHP Intelephense, PHP Intellisense, PHP Lightweight Toolbox, PHP Namespace Resolver, PHP Symbols.Chubb
I didn't find settings for manage suggestions, how can i solve this problem? By deleting extensions?Chubb
I solve this problem by uninstalling and then reinstalling the pylance extension.Delrosario
W
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.

Wriest answered 12/9, 2018 at 6:42 Comment(7)
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?Chubb
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?Margarito
I just want to know what other php developers do with this thing. Nothing?Chubb
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.Margarito
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.Chubb
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.Margarito
Thank you, this addition is exactly what I need!Chubb
T
19

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.

Trachyte answered 17/8, 2022 at 18:53 Comment(4)
Weird, same behavior on my side. Disabling pylance and enabling it back solved the issue.Wellintentioned
Thanks for this, was driving me nuts but disabling/reenabling pylance solved for me as well!Loredo
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.Trachyte
Same here in terms of the recurring nature :(, I'll see if I can isolate a competing extensionLoredo
W
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.

Wriest answered 12/9, 2018 at 6:42 Comment(7)
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?Chubb
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?Margarito
I just want to know what other php developers do with this thing. Nothing?Chubb
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.Margarito
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.Chubb
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.Margarito
Thank you, this addition is exactly what I need!Chubb
L
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.

Loredo answered 28/11, 2022 at 21:27 Comment(2)
Looks like there's always a bug request out, added my notes so we'll see what happens! github.com/microsoft/vscode-jupyter/issues/12029Loredo
This is the real MVP!!Narcho
C
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.

Cost answered 1/12, 2022 at 3:57 Comment(1)
Ha, you're right! The root cause is different but the same for me ;)Profundity

© 2022 - 2024 — McMap. All rights reserved.