microsoft / vscode-cpptools

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

Incorrect tokens highlight with "requires" clause with brackets #12356

Closed demidenko closed 3 months ago

demidenko commented 3 months ago

Environment

Bug Summary and Steps to Reproduce

Bug Summary: This image contains basic example code изображение

On this image one can see that some keywords colors are reset to white

Meanwhile if requires condition used greater instead of less then outer tokens highlighted correctly and only inner are reset to white изображение

In basic code if brackets after requires are missing (which will lead to compilation error) then highlight looks correct everywhere изображение

Steps to reproduce: create cpp file with basic example code

void fun(auto a) requires (true && 1 < 2 && true) {

}

int main() {
    for(int i=0; i <= 10; ++i)
        if(i % 2 == 0) fun(i);
    return 0;
}

Expected behavior: correct colors on tokens for, return, if, true, <=, etc.

Configuration and Logs

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "c17"
        }
    ],
    "version": 4
}

Other Extensions

No response

Additional context

Real code triggering this issue was

auto& operator<<(ostream &o, ranges::range auto &&r) requires(!requires{o<<r;}) {

so situation is not synthetic

sean-mcmanus commented 3 months ago

Our extension doesn't implement the lexical highlighting in this case. It comes from VS Code and the Better C++ extension (which VS Code relies on). I believe the issue tracking this is https://github.com/jeff-hykin/better-cpp-syntax/issues/638 .