vscode 启动的许多 rg 命令消耗了 99% 的 CPU

zyx*_*xue 7 python git visual-studio-code ripgrep

我正在一个非常大的 github 存储库中工作,假设它的结构是这样的

\n
project-root\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 project-1\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 subproject-a\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 subproject-others\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 project-2\n    \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 subproject-b\n    \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 subproject-others\n
Run Code Online (Sandbox Code Playgroud)\n

有很多项目,每个项目又包含很多子项目。我正在研究其中一个子项目(例如subproject-a)。当我在子项目(它是一个 python 子项目)中打开 vscode 时,我注意到它启动了许多rg如下命令,并且我的 CPU 使用率超过 99%。我想知道这些 rg 命令是关于什么的?他们只是在子项目中搜索内容,还是在包含数万个文件的整个 git 存储库中搜索内容?为什么他们要消耗这么多资源?请问我怎样才能避免这种情况?

\n
\n

/Applications/Visual Studio Code.app/Contents/Resources/app/node_modules.asar.unpacked/vscode-ripgrep/bin/rg --files --hidden --case-sensitive -g **/*.go/** -g **/*.go -g !**/.git -g !**/.svn -g !**/.hg -g !**/CVS -g !**/.DS_Store -g !**/.classpath -g !**/.factorypath -g !**/.project -g !**/.settings -g !**/node_modules -g !**/bower_components -g !**/*.code-search --no-ignore-parent --follow --quiet --no-config --no-ignore-global

\n
\n

zyx*_*xue 3

事实证明,有四个符号链接文件夹,其中包含超过 70 万个文件。这些文件夹通常在/project-root/.gitginore. 因此rg默认情况下会忽略在其中的搜索。

但在这里,由于--no-ignore-parent --follow旗帜的存在,他们仍然受到搜查。

/project-root/project-1/subproject-a/.gitignore再次添加了这些文件夹,现在这些rg命令不再占用那么多的 cpu 资源。