microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.52k stars 1.56k forks source link

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

Open cmsong-shina opened 2 years ago

cmsong-shina commented 2 years ago

Environment

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

Colengms commented 2 years ago

Hi @cmsong-shina . Bracket pair colorization is a feature the core engine of VS Code. I'm not aware of a way to influence this feature via the API extensions use to integrate with VS Code.

I opened the following issue against VS Code. When that is addressed, it should allow us to correct this issue.

https://github.com/microsoft/vscode/issues/163954

setian commented 1 year ago

Its not only bracket problem other sentance also enabled...

tomasz-kaczmarek commented 1 year ago

I am curious is this example can be related: image

    #if defined(A) // comment
        #define B // comment
    #endif

    #if defined(A)
        #define B
    #endif

    #if defined(A)
        #define B // comment
    #endif

    #ifdef A
        #define B // comment
    #endif

    #if defined(A) // comment
        #define B
    #endif
sean-mcmanus commented 1 year ago

@tomasz-kaczmarek That issue is not related. Can you check if it repros with our C/C++ extension disabled? If not, can you file a new bug with more repro info, because I don't repro that.