microsoft / microsoft/vscode-cpptools

Single line comment after `#if` directives spoil scope highlight.

Open
#10,022 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Environment
  • OS and Version:
    tested with Windows and SSH(Windows + Linux)
    • Windows 11 22000.1098
    • (ssh) Windows 11 22000.1098 + Pop!_OS 22.04 LTS
  • VS Code Version:1.72.2
  • C/C++ Extension Version: v1.12.4
  • Other extensions you installed (and if the issue persists after disabling them):
    • MS-CEINTL.vscode-language-pack-ko
    • ms-vscode.cpptools-extension-pack
    • twxs.cmake
    • ms-vscode.cmake-tools
      yes the issue peresists after disable thoese.
  • If using SSH remote, specify OS of remote machine:
    • Pop!_OS 22.04 LTS
  • A clear and concise description of what the bug is, including information about the workspace (i.e. is the workspace a single project or multiple projects, size of the project, etc).
Bug Summary and Steps to Reproduce

Just create single main.c file and paste the code.

Expected behavior
problem_1

Brace next #if 0 should be ignored but it is not.

no_problem_2

When I put new line it fine.

no_problem_1

And multi line comment also fine.

Code sample and Logs

main.c

int main(void)
{
#if 0 // a
    {
        printf("hello");
#else
    {
        printf("good bye");
#endif
        printf(" world");
    }
}

setting.json

{
    "[c]": {
        "editor.semanticHighlighting.enabled": true,
        "editor.tabSize": 4
    },
    "files.associations": {
        "*.h": "c"
    }
}

no notable output from C/C++: Log Diagnostics and language server.

Screenshots
problem_1 no_problem_1 no_problem_2
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 with the main.c reproduction in the issue and inspect how the C/C++ extension handles semantic highlighting for #if directives with a single-line comment. Verify the behavior with the provided setting.json and confirm that braces under #if 0 are excluded from scope highlighting while the multiline and newline cases remain correct.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.