microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incorrect tokens highlight with "requires" clause with brackets

demidenko opened this issue · comments

Environment

  • OS and Version: Ubuntu 24.04
  • VS Code Version: 1.90.0
  • C/C++ Extension Version: v1.20.5
  • If using SSH remote, specify OS of remote machine:

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

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 jeff-hykin/better-cpp-syntax#638 .