VS代码需要几秒钟才能将文档保存在C++
这是/home/user/.config/code/user/settings.json
中的C/C ++
"C_Cpp.formatting": "clangFormat",
"C_Cpp.default.intelliSenseMode": "linux-clang-x64",
"C_Cpp.dimInactiveRegions": false,
"C_Cpp.clang_format_path": "/usr/bin/clang-format",
"C_Cpp.clang_format_sortIncludes": true,
"C_Cpp.codeAnalysis.clangTidy.enabled": true,
"C_Cpp.codeAnalysis.clangTidy.path": "/usr/bin/clang-tidy",
"C_Cpp.default.cppStandard": "c++23",
"C_Cpp.default.cStandard": "c17",
"C_Cpp.autocompleteAddParentheses": true,
"C_Cpp.default.compilerPath": "/usr/bin/clang"
配置不是:
但是,当我尝试在Rust中开发时,此问题不存在:
我如何解决这个问题,因为它很烦人?
还有一种方法可以查看保存VS代码时发生的事情,以便我知道导致此延迟的过程是什么?
This is my C/C++ configs in /home/user/.config/Code/User/settings.json
:
"C_Cpp.formatting": "clangFormat",
"C_Cpp.default.intelliSenseMode": "linux-clang-x64",
"C_Cpp.dimInactiveRegions": false,
"C_Cpp.clang_format_path": "/usr/bin/clang-format",
"C_Cpp.clang_format_sortIncludes": true,
"C_Cpp.codeAnalysis.clangTidy.enabled": true,
"C_Cpp.codeAnalysis.clangTidy.path": "/usr/bin/clang-tidy",
"C_Cpp.default.cppStandard": "c++23",
"C_Cpp.default.cStandard": "c17",
"C_Cpp.autocompleteAddParentheses": true,
"C_Cpp.default.compilerPath": "/usr/bin/clang"
Now when i try to save a C++ document, sometimes it takes several seconds to save and sometimes not:
However when i try developing in Rust, this problem does not exist:
How can i fix that problem as it is so annoying?
Also is there a way to see what's happening while saving in vs code so that i can know what is the process that causes this delay?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在VSCODE中,我试图禁用我之前安装的所有扩展程序,我一个一个接一个地禁用它们,在每次禁用后,我通过更改代码然后保存的代码测试,但问题仍然存在,直到所有扩展名关闭为止。
然后我想起还有其他一些内置扩展。我打开了扩展名,然后按在左侧栏右上方的三个点上,然后我选择
显示运行扩展
,运行扩展
将打开,您将找到其中的git。我注意到git在无响应中,除了4000+MS
之外,它的数量大于所有其他扩展。请注意,我正在使用git版本
2.34.1
。在生锈开发过程中,GIT扩展也可以响应。因此,我将git更新为最新版本,该版本是
2.37.1
使用以下命令:sudo addo add-apt-repository ppa:git-core/ppa
sudo apt apt Update
sudo apt install git
现在我重新启动了VSCODE,git扩展程序响应且正常工作。另外,节省很快,一切都很好。
问题归因于我所知,仅在C ++开发中扩展了无反应的GIT。因此,将git更新到最新版本。
更新:
我认为即使将GIT更新为最新版本后,问题仍然存在。延迟仍然仅在C ++开发中发生。一旦我使用

git Init
在工作目录中初始化了git,就可以解决该问题。当我重新启动VSCODE时,一切正常。这是问题存在时运行扩展的屏幕截图(请注意第一个GIT扩展程序):更新:
我想我知道问题所在。我的C ++项目的目录是
/home/user/user/projects/cpp/testing_1
,在cpp/
目录中,我放置了所有我的C ++项目,例如testing_1/< /code>,
testing_2/
等等。我在cpp/
dir中初始化的git在此之前是我所有项目的父级。当我删除.git
cpp/
dir时,即使我在工作项目中不初始化git,例如testing_1 /
。我认为您的项目的父母dir中不初始化git解决了问题。我会看到那走的地方。In vscode, i tried to disable all the extensions that i installed previously, i disabled them one by one, after each disable, i test by changing the code then saving, yet the problem persists, until all the extensions are off.
Then i remembered there are some other built-in extensions. I opened the extensions, then pressed on the three dots at the top right of the left side bar, then i chose
Show running extensions
, theRunning extensions
will open and you will find among them git. I noticed that git in unresponsive and had a huge number beside it like4000+ms
which is substantially greater than all the other extensions.Notice that i am using git version
2.34.1
. Also the git extension is ok and responsive during Rust development.So i updated git to the latest version which is
2.37.1
using these commands:sudo add-apt-repository ppa:git-core/ppa
sudo apt update
sudo apt install git
Now i restarted vscode and the git extension is responsive and working properly. Also the saving is fast and everything in fine.
The problem was due to unresponsive git extension only in C++ development as far as i know. So update git to the latest version.
Update:
I think the problem still exists even after i updated git to the latest version. The delay still only happens with C++ development. The problem is solved once i initialized git in my working directory using

git init
. When i restart vscode, everything works fine. Here is a screenshot of the Running extensions when the problem exists (Notice the first git extension):Update:
I think i knew where the problem is. The directory of my C++ project is
/home/user/Projects/cpp/testing_1
, incpp/
directory i put all my C++ projects such astesting_1/
,testing_2/
and so on. I initialized git incpp/
dir before which is the parent dir of all my projects. When i deleted that.git
dir incpp/
the git extension in responsive and working fine, even when i am not initializing git in my working project such astesting_1/
. I think not initializing git in the parent dir of your project solved the problem. I will see where that goes.