简体   繁体   English

Visual Studio Code Intellisense 非常慢——有什么我可以做的吗?

[英]Visual Studio Code Intellisense is very slow - Is there anything I can do?

Edit: Pylance seems to be much better at this and has so far resolved all problems with the previous Python language server from Microsoft.编辑:Pylance 似乎在这方面做得更好,到目前为止已经解决了 Microsoft 以前的 Python 语言服务器的所有问题。

I'm using VS Code and it's wonderful is all areas but code completion, where it is usually just too slow to be of any use.我正在使用 VS Code,除了代码完成之外的所有领域都很棒,它通常太慢而无法使用。 This example shows how long intellisense took to to find a local variable, and this is only after it was prompted to do so after I hit ctrl+enter.这个例子显示了智能感知需要多长时间才能找到一个局部变量,这只是在我按下 ctrl+enter 提示它这样做之后。

在此处输入图像描述

I've not been able to find a solution to this as of yet, so I am here to ask if anyone else has had a similar issue and ask how they have overcome it.到目前为止,我还没有找到解决办法,所以我在这里问问有没有其他人遇到过类似的问题,并询问他们是如何克服的。

It turned out it was a particular VS Code extension for me.事实证明,它对我来说是一个特殊的 VS Code 扩展。
Angular Language Service.角语言服务。 Disabling this made it lightning quick.禁用它使它闪电般快速。

Try this to see if it is a particular extension.试试这个,看看它是否是一个特定的扩展。

  • Open Command Palette (Ctrl+Shift+P)打开命令面板 (Ctrl+Shift+P)
  • Type in "Disable all installed extensions"输入“禁用所有已安装的扩展”
  • Enable them one by one or in groups and test the intellisense speed一对一或分组启用并测试智能感知速度

The problem might be with wrong setting configuration.问题可能出在错误的设置配置上。
You might want to make sure these setting are on:您可能希望确保这些设置已启用:

Controls if suggestions should automatically show up while typing控制是否应在键入时自动显示建议

"editor.quickSuggestions": {
  "other": true,
  "comments": false,
  "strings": false
},

Controls the delay in ms after which quick suggestions will show up控制以毫秒为单位的延迟,之后将显示快速建议

"editor.quickSuggestionsDelay": 10,

Maybe it's Jedi .也许是绝地武士 I mean its awesome but ... Tinkering with Jedi myself on bigger code bases I can confirm that it might be uber slow at times and pretty hard to figure out what the problems are... :/我的意思是它很棒但是......在更大的代码库上修补绝地我可以确认它有时可能非常慢并且很难弄清楚问题是什么......:/

Solution might be to switch to another language server!解决方案可能是切换到其他语言服务器! The VSCode Python extension has a "Language Server"-setting: VSCode Python 扩展有一个“语言服务器”设置:

在此处输入图片说明

aka python.languageServer .又名python.languageServer

Pylance is MS own new language server. Pylance是 MS 自己的新语言服务器。 I just tried it and it all seems a little snappier.我刚试过,这一切似乎有点快。 As of today this is tagged as Preview .截至今天,这被标记为Preview So there might be improvements around the corner.所以可能会有改进。

My answer's for c++ but still kinda related.我的答案是针对 C++,但仍然有点相关。

I'm using the C/C++ extension from Microsoft, and when I switched its Intelli Sense Engine setting from Default , with "context-aware results", to Tag Parser , with "'fuzzy' results that are not context-aware", it immediately started showing IntelliSense options instead of delaying for 5+ seconds.我正在使用来自 Microsoft 的 C/C++ 扩展,当我将其Intelli Sense Engine设置从Default切换到“上下文感知结果”到Tag Parser ,“'模糊'结果不是上下文感知”,它立即开始显示 IntelliSense 选项,而不是延迟 5 秒以上。

So maybe check the particular options of your language's or environment's extension(s).因此,也许可以检查您的语言或环境扩展名的特定选项。

I had the same problem with Python on VS Code.我在 VS Code 上使用 Python 时遇到了同样的问题。 In my case, disabling Jedi for IntelliSence made things faster.就我而言,禁用 IntelliSence 的绝地使事情变得更快。

Just set "python.jediEnabled": false in the options.只需在选项中设置"python.jediEnabled": false

As memory is not a problem for me, I also enabled code analysis to keep parser trees in memory: "python.analysis.memory.keepLibraryAst": true由于内存对我来说不是问题,我还启用了代码分析以将解析器树保存在内存中: "python.analysis.memory.keepLibraryAst": true

Open Command Palette ( Ctrl + Shift + P )打开命令面板( Ctrl + Shift + P

命令调色板

Select Developer: show running extension选择开发者:显示正在运行的扩展

You will get their list of extensions and their reboot time您将获得他们的扩展列表和重启时间列表

If extension takes more than 500ms to activate there seems to be a problem with it如果扩展需要超过 500 毫秒才能激活,则它似乎有问题

You can press on right click and stop it您可以按右键单击并停止它

右键点击

more details... 更多细节...

If you're working with Angular and noticed intellisense slowness in the past days, it could be Angular Language Service with its new Experimental-ivy feature.如果您正在使用 Angular 并且在过去几天注意到智能感知缓慢,那么它可能是具有新的Experimental-ivy功能的Angular 语言服务

You can disable it by opening the extension settings:您可以通过打开扩展设置来禁用它:

管理扩展 UI

Then disable the Experimental-ivy feature:然后禁用实验常春藤功能:

禁用常春藤


VS Code prompted me to enable it at some point, I enabled and since then intellisense is super slow. VS Code 在某个时候提示我启用它,我启用了它,从那时起智能感知超级慢。 By disabling this with the steps above, now it's fast again.通过使用上述步骤禁用此功能,现在又快了。

提示对话框

I had the same problem.我有同样的问题。 Disabling the checkbox for the "Snippets Prevent Quick Suggestions" option in VSCode settings seems to solve the problem of the loading time.在 VSCode 设置中禁用“Snippets Prevent Quick Suggestions”选项的复选框似乎解决了加载时间的问题。

Disable Quick Preview禁用快速预览

my issue was solved by disabling this extension that was not installed completely我的问题已通过禁用未完全安装的扩展解决

Visual Studio IntelliCode Visual Studio 智能代码

For me, I had installed the Arduino extension.对我来说,我已经安装了 Arduino 扩展。
This was problematic as it thought it should be in use every time I was coding in C++ so it was really slowing down the autocompletes.这是有问题的,因为它认为每次我用 C++ 编码时都应该使用它,所以它真的减慢了自动完成的速度。

I just disabled it for my workspace and everything work really quickly我只是为我的工作区禁用了它,一切都很快

对我来说奇怪的解决方案,但禁用然后重新启用所有扩展为我解决了这个问题。

None of these solutions worked for me.这些解决方案都不适合我。 What worked for me, is that I went to the extension settings and:对我有用的是,我进入了扩展设置,然后:

  • changed IntelliSense mode to windows-gcc-arm64 (I was selecting different options for this one based on my os, till I found the fastest one)将 IntelliSense 模式更改为 windows-gcc-arm64(我根据我的操作系统为这个模式选择了不同的选项,直到我找到了最快的一个)

  • changed IntelliSense update delay from 2000 to 500 (this added a bigger boost, after the first boost from a change in IntelliSense mode)将 IntelliSense 更新延迟从 2000 更改为 500(在 IntelliSense 模式更改的第一次提升之后,这增加了更大的提升)

在 settings.json 文件中使用以下值

"editor.suggest.snippetsPreventQuickSuggestions": false,

I used git without .gitignor e.我使用 git 没有.gitignor e。 Add .gitignore and add unnecessary files and directories like virtualenv in that.添加.gitignore并在其中添加不必要的文件和目录,例如 virtualenv。

Click the Windows key and R at the same time, then type %temp%, then find.vscode file.同时点击Windows键和R,然后输入%temp%,然后找到.vscode文件。 Delete it.删除它。 Happy coding.快乐的编码。

I had the same issue, I disabled extensions one by one.我有同样的问题,我一个一个地禁用了扩展。 Disabling "Live Server (v5.7.9)" extension fixed it for me.禁用“Live Server (v5.7.9)”扩展为我修复了它。

You could check as previously suggested, to disable some extensions and retry using the reference finder function.您可以按照之前的建议进行检查,以禁用某些扩展并使用参考查找器 function 重试。

For my case, the Makefile Tools extension ( https://marketplace.visualstudio.com/items?itemName=ms-vscode.makefile-tools ), minutes after overtaking C/C++ IntelliSense, it just plainly broke over and over.就我而言,Makefile 工具扩展 ( https://marketplace.visualstudio.com/items?itemName=ms-vscode.makefile-tools ),在超过 C/C++ IntelliSense 几分钟后,它显然一次又一次地崩溃。

For me it was the "Multiple clipboards for VSCode" extension, disabling it fixed my issues.对我来说,它是“VSCode 的多个剪贴板”扩展,禁用它解决了我的问题。

Disable all Extension and Restart one by one禁用所有扩展并一一重新启动

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM