ITADN

C_Cpp.ResetDatabase does not recover IntelliSense for newly created files when CMake Tools is the configurationProvider

#4953Openyo35 创建于 2026-05-22
bugmore info needed
Y
yo35commented
## Summary When a new `.cpp`/`.h` file is created inside VS Code in a CMake project (where CMake Tools is the IntelliSense `configurationProvider`), IntelliSense permanently fails for that file until `Developer: Restart Extension Host` or a full VS Code restart is performed. Running `cmake.configure` followed by `C_Cpp.ResetDatabase` does NOT fix the issue. ## Environment - cpptools: 1.32.2 - cmake-tools: 1.23.52 - OS: Linux (Ubuntu) - Multi-root workspace (10 folders) - CMake project uses `file(GLOB_RECURSE ... CONFIGURE_DEPENDS ...)` for sources ## Steps to Reproduce 1. Open a CMake project with CMake Tools as the IntelliSense provider (no `c_cpp_properties.json`, no `C_Cpp.default.compileCommands`) 2. Create a new `.cpp` file inside VS Code — it opens immediately, IntelliSense starts failing (expected, cmake has not re-configured yet) 3. Run **CMake: Configure** — the code model is updated, the new file appears in `.cmake/api/v1/reply/target-*.json` with the correct include paths, and `compile_commands.json` also contains the correct entry with `-isystem` paths 4. Run **C/C++: Reset IntelliSense Database** 5. Re-open the new file **Expected:** IntelliSense works — include paths are found, no errors **Actual:** IntelliSense still shows include errors: ``` #include errors detected based on information provided by the configurationProvider. Squiggles are disabled for this translation unit. ``` System includes (from `-isystem` / `isSystem=true` in the CMake code model) are not found. ## Key Observation - **Existing files** (present before the current VS Code session) work correctly with identical CMake code model include paths — no IntelliSense errors. - **Only newly created files** in the current session fail, even after `cmake.configure` + `C_Cpp.ResetDatabase`. - **`Developer: Restart Extension Host`** fixes the issue immediately. ## Root Cause Hypothesis When a new file is first opened, cpptools requests its configuration from CMake Tools. If cmake has not re-configured yet, CMake Tools returns no configuration for that URI. Cpptools caches this "no configuration" state. After `cmake.configure`, CMake Tools fires a `configurationChanged` event. However, files previously in "no configuration" state appear to not be re-queried. `C_Cpp.ResetDatabase` clears the symbol index and restarts the language server, but the stale provider-relationship state for the "no config" file persists. Only a full extension host restart (which also re-initializes CMake Tools, clearing all provider state) resolves the issue. ## Expected Behavior of `C_Cpp.ResetDatabase` `C_Cpp.ResetDatabase` should perform a full reset equivalent to restarting the extension host, including re-requesting IntelliSense configurations from all registered `configurationProvider`s for all currently open files — including files that were previously in a "no configuration" state. ## Workaround Use **`Developer: Restart Extension Host`** instead of `C_Cpp.ResetDatabase`. Alternatively, create new files from outside VS Code (e.g. terminal `touch`), run `cmake.configure`, then open the files — IntelliSense works on first open. ## Related Issue See also: https://github.com/microsoft/vscode-cmake-tools/issues/1479 ("Provide configuration information for nearby files", marked stale)
8 条评论