microsoft / vscode-cpptools

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

Special cases where variables are highlighted in the color of the macro definition #12321

Open meijialun opened 3 months ago

meijialun commented 3 months ago

Environment

Bug Summary and Steps to Reproduce

Bug Summary: Special cases where variables are highlighted in the color of the macro definition

Steps to reproduce:

  1. Define two macro definitions, with macro definition 1 pointing to macro definition 2, and macro definition 2 pointing to an assignment statement, with macro definition 2 being longer than macro definition 1
  2. Use macro definition 1 and macro definition 2 respectively
  3. Macro Definition 1 has incorrect syntax highlighting in parentheses, but Macro Definition 2 is correct
  4. Local variables within the brackets of macro definition 1 are partially highlighted in the color of the macro definition and depend on the length of macro definition 2

Expected behavior: Variables are correctly highlighted

Snipaste_2024-05-22_10-56-29

Configuration and Logs

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [
                "__TASKING__",
                "BRS_COMP_TASKING"
            ],
            "windowsSdkVersion": "10.0.19041.0",
            "compilerPath": "",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "linux-gcc-x64"
        }
    ],
    "version": 4
}

Other Extensions

No response

Additional context

No response

meijialun commented 3 months ago

issue12321.zip This is the test code

bobbrow commented 3 months ago

Hi @meijialun,

Thank you for the bug report. We saw this in Visual Studio too. A fix was made and we will get it in VS Code the next time we update the language server.