microsoft / microsoft/vscode-cpptools

Inactive code regions with #include fail

Open
#13,029 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Language Service Visual Studio
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Environment
  • OS and Version: W10
  • VS Code Version: 1.95.3
  • C/C++ Extension Version: 1.22.11 and also 1.23.2 (pre release)
  • CMake Tools extension v1.19.52
Bug Summary and Steps to Reproduce

Bug Summary:

The disabled code region fail on simple case.
I'm using CMake and the MSVC 2022 C compiler, with the following simple code

#define USE_FIRST
#define USE_ANTYHING

#if defined(USE_FIRST)
    #include <stdio.h>
#elif defined(USE_SECOND)
    #include <stdio.h>
#else
    #error Either USE_FIRST or USE_SECOND must be defined
#endif

int main(int argc, char *argv[]) {
    printf("Main executed\r\n");
    return 0;
}

The normal output is the following:
Image

However sometimes it's failing
For example when you press one or two times the Ctrl+S (save file) then the disabled dimed area fail:
Image

Steps to reproduce:

You can check the simple code here to reproduce, it use CMake:
Bug.zip

Configuration and Logs
Here is the generated `c_cpp_properties.json`


{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.22000.0",
            "compilerPath": "cl.exe",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "windows-msvc-x64",
            "configurationProvider": "ms-vscode.cmake-tools"
        }
    ],
    "version": 4
}
Other Extensions

No response

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by opening Bug.zip and reproducing the issue with the supplied CMake project, then inspect the generated c_cpp_properties.json and the conditional code shown in the report. Save the file once or twice and verify that inactive regions containing #include remain correctly dimmed afterward.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cmake, typescript
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.