-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Environment
- OS and Version: window 23H2 wsl2 unbuntu 22.04 lts
- VS Code Version: version 1.106
- C/C++ Extension Version: 1.28.3
- If using SSH remote, specify OS of remote machine:
Bug Summary and Steps to Reproduce
Bug Summary: IntelliSense inactive regions reset (flicker) to active state on file save when using compile_commands.json in WSL.
Steps to reproduce:
Setup a C project in WSL2 using the Microsoft C/C++ extension and generate a compile_commands.json (e.g., using bear).
Configure .vscode/c_cpp_properties.json to use "compileCommands": "${workspaceFolder}/compile_commands.json" and strictly set "includePath": [] (empty).
The project supports multiple build targets. The preprocessor definitions in compile_commands.json dynamically switch between -DTARGET_IMX93 and -DTARGET_IMX8MP for the same source file depending on the selected configuration.
Build for one target (e.g., TARGET_IMX8MP) so that compile_commands.json is updated with -DTARGET_IMX8MP.
Open a source file (.c) containing conditional preprocessor blocks (#ifdef / #else) where one block should be inactive (dimmed) based on the defines in compile_commands.json.
Observe that the inactive region is correctly dimmed initially.
Press Ctrl+S to save the file.
See error: The dimmed inactive region immediately becomes active (opaque/bright) again, ignoring the compile_commands.json configuration.
Additional Context (Comparison with Clangd extension): The vscode-c/c++ (cpptools) extension fails to maintain the state, but the clangd extension works perfectly. When I disable the Microsoft C/C++ extension and use the clangd extension with the exact same compile_commands.json and project structure, the inactive regions are handled correctly and persist even after saving.
c_cpp_properties.json
{
"configurations": [
{
"name": "Linux",
"includePath": [],
"compileCommands": "${workspaceFolder}/compile_commands.json",
"cStandard": "c17",
"cppStandard": "c++17"
}
],
"version": 4
}
Configuration and Logs
Diagnostics
-------- Diagnostics - 12/3/2025, 5:42:20 PM
Version: 1.28.3
Current Configuration:
{
"name": "Linux",
"includePath": [],
"compileCommands": [
"/home/leejunggyun/workplace/test/multi_source/compile_commands.json"
],
"cStandard": "c17",
"cppStandard": "c++17",
"compilerPathIsExplicit": false,
"cStandardIsExplicit": true,
"cppStandardIsExplicit": true,
"intelliSenseModeIsExplicit": false,
"recursiveIncludesReduceIsExplicit": false,
"recursiveIncludesPriorityIsExplicit": false,
"recursiveIncludesOrderIsExplicit": false,
"compileCommandsInCppPropertiesJson": [
"${workspaceFolder}/compile_commands.json"
],
"mergeConfigurations": false,
"recursiveIncludes": {},
"browse": {
"limitSymbolsToIncludedHeaders": true
}
}
Additional Tracked Settings:
{
"editorTabSize": 4,
"editorInsertSpaces": true,
"editorAutoClosingBrackets": "languageDefined",
"filesEncoding": "utf8",
"filesAssociations": {
"menu_device_imx8mp.h": "c",
"menu_device_imx93.h": "c"
},
"filesExclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/.DS_Store": true,
"**/Thumbs.db": true
},
"filesAutoSaveAfterDelay": false,
"editorInlayHintsEnabled": true,
"editorParameterHintsEnabled": true,
"searchExclude": {
"**/node_modules": true,
"**/bower_components": true,
"**/*.code-search": true
},
"workbenchSettingsEditor": "ui"
}
cpptools version (native): 1.28.3.0
Current database path: /home/leejunggyun/.cache/vscode-cpptools/07d841cfe44854793ff5abba64262a39/.browse.VC.db
Translation Unit Mappings:
[ /home/leejunggyun/workplace/test/multi_source/main.c - source TU]:
Translation Unit Configurations:
[ /home/leejunggyun/workplace/test/multi_source/main.c ]
Process ID: 27178
Memory Usage: 21 MB
Compiler Path: /usr/bin/gcc
Include paths:
include: /home/leejunggyun/workplace/test/multi_source/menu/include
system include: /usr/lib/gcc/x86_64-linux-gnu/11/include
system include: /usr/local/include
system include: /usr/include/x86_64-linux-gnu
system include: /usr/include
Defines:
TARGET_IMX93
Standard Version: c17
IntelliSense Mode: linux-gcc-x64
Other Flags:
--gcc
--gnu_version=110400
compile_commands.json entry:
directory: /home/leejunggyun/workplace/test/multi_source
file: /home/leejunggyun/workplace/test/multi_source/main.c
arguments:
/usr/bin/gcc
-Imenu/include
-Wall
-DTARGET_IMX93
-c
-o
main.o
main.c
output: /home/leejunggyun/workplace/test/multi_source/main.o
Total Memory Usage: 21 MB
Browse Paths from compile_commands.json, from workspace folder: /home/leejunggyun/workplace/test/multi_source
/home/leejunggyun/workplace/test/multi_source
/home/leejunggyun/workplace/test/multi_source/menu
/home/leejunggyun/workplace/test/multi_source/menu/include
/usr/include
/usr/include/c++/12
/usr/include/c++/12/backward
/usr/include/x86_64-linux-gnu
/usr/include/x86_64-linux-gnu/c++/12
/usr/lib/gcc/x86_64-linux-gnu/11/include
/usr/lib/llvm-14/lib/clang/14.0.0/include
/usr/local/include
------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 8166compile_commands.json
[
{
"arguments": [
"/usr/bin/gcc",
"-Imenu/include",
"-Wall",
"-DTARGET_IMX93",
"-c",
"-o",
"main.o",
"main.c"
],
"directory": "/home/leejunggyun/workplace/test/multi_source",
"file": "/home/leejunggyun/workplace/test/multi_source/main.c",
"output": "/home/leejunggyun/workplace/test/multi_source/main.o"
},
{
"arguments": [
"/usr/bin/gcc",
"-Imenu/include",
"-Wall",
"-DTARGET_IMX93",
"-c",
"-o",
"menu/menu_device_imx93.o",
"menu/menu_device_imx93.c"
],
"directory": "/home/leejunggyun/workplace/test/multi_source",
"file": "/home/leejunggyun/workplace/test/multi_source/menu/menu_device_imx93.c",
"output": "/home/leejunggyun/workplace/test/multi_source/menu/menu_device_imx93.o"
}
]Other Extensions
No response
Additional context
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status