每次保存文件时,VSC IntelliSense 都会暂停

问题描述 投票:0回答:1

我在 Ubuntu 24.04 中使用 Visual Studio Code 1.93.0 并具有以下扩展:

  • C/C++ v1.22.2
  • ESP-IDF v1.8.1
  • PlatformIO IDE v3.3.3

以及其他一些与具体问题无关的内容。 当我打开使用 PlatformIO IDE 和 C++ 的项目时,IntelliSense 工作正常:语法突出显示、自动完成、导航(声明/实现)、重构等...

几天以来,当我打开一个使用 ESP-IDF 和 C 的项目时,需要几分钟才能使用上述所有功能。每次我保存文件时,他们都会停止工作几分钟。

我尝试:

  • C/C++ 重置 IntelliSense 数据库
  • C/C++ 重新扫描工作区
  • 检查 VSC 更新
  • 检查扩展更新

但问题并没有得到解决。 我还注意到,每次保存文件时(直到功能再次可用),进程

cpptools-srv
都非常活跃,CPU 占用率约为 4%,RAM 使用率最低。因此,我认为这与here描述的问题不同。

这是我的

settings.json

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "${config:idf.espIdfPath}/components/**"                
            ],
            "defines": [],
            "compilerPath": "${config:idf.toolsPath}/tools/xtensa-esp-elf/esp-13.2.0_20240530/xtensa-esp-elf/bin/xtensa-esp32s3-elf-gcc",
            "cStandard": "c17",
            "cppStandard": "gnu++17",
            "intelliSenseMode": "linux-gcc-x64"
        }
    ],
    "version": 4
}

还有我的

c_cpp_properties.json

{
    "idf.adapterTargetName": "esp32s3",
    "idf.flashType": "UART",
    "idf.port": "/dev/ttyACM0",
    "files.associations": {
        "usb_serial_jtag_vfs.h": "c",
        "uart_vfs.h": "c",
        "common.h": "c",
        "i2c_master.h": "c",
        "modbus_params.h": "c",
        "esp_mac.h": "c",
        "freertos.h": "c",
        "datetime.h": "c",
        "time.h": "c",
        "time_t.h": "c",
        "condition_variable": "c",
        "ctime": "c",
        "mutex": "c",
        "shared_mutex": "c",
        "spi_master.h": "c",
        "task_wifi.h": "c"
    }
}

更新

按照用户starball的提示,我运行了扩展bisect,发现罪魁祸首是

ms-vscode.cpptools
。当然,禁用扩展并不是解决方案!奇怪的是,在其他项目中它运行良好。

如何找出问题的根本原因?

c++ visual-studio-code intellisense esp-idf
1个回答
0
投票

我不知道问题是否解决,但我会以我的案例为例给你解决方案。

就我而言,最新版本的 C/C++ 扩展是问题的原因。存在一些与代码文件的符号链接相关的问题。换句话说,扩展程序无法识别 Intellisense 中的某些文件。

我多次修改 .json、更新 VS Code、重新安装扩展等等。但没有像你的情况那样改变。

介绍了这么长,解决方案如下: “将您的 C/C++ 扩展降级到 1.19.9 版本”

  1. 转到 C/C++ 扩展
  2. 单击“卸载”按钮旁边的下拉箭头
  3. 单击“安装另一个版本”
  4. 选择1.19.9版本
  5. 完成!

然后您可以看到 C/C++ Intellisense 正常工作。

© www.soinside.com 2019 - 2024. All rights reserved.