vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

Semantic highlighting isn't working with CreateWindow macros

Open sean-mcmanus opened this issue 2 years ago • 5 comments

          I also have a macro-related issue; not sure if this is intended.

When using macros defined in other files, sometimes the tokens/scopes are incorrect for macros inside the macro call.

For example: image CW_USEDEFAULT is a windows macro but for some reason it is white instead of blue since it doesn't have entity.name.function.preprocessor.cpp as the foreground.

However, when I define my own macros, the macros are now blue which seems to be correct: image

So this highlighting is inconsistent.

Originally posted by @billgan1024 in https://github.com/microsoft/vscode-cpptools/issues/11248#issuecomment-1710909472

sean-mcmanus avatar Sep 08 '23 00:09 sean-mcmanus

You appear to not be getting semantic highlighting for those macros in the CreateWindow call. Is IntelliSense working at that point or has it crashed? Do you see a "semantic token type" when viewing the token/scopes for the CreateWindow call?

Are you able to provide a simple repro? We could also try to see if can repro it ourselves based on the screenshot info...

sean-mcmanus avatar Sep 08 '23 00:09 sean-mcmanus

Intellisense still seems to be working because I reloaded it: image

but there's still no semantic highlighting.

Here is a simple repro:

#include <windows.h>
#define TITLE L"Test"
int WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
    HWND window = CreateWindow(
        TITLE,
        TITLE, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
        CW_USEDEFAULT,
        CW_USEDEFAULT,
        800,
        600,
        0,
        0,
        0,
        0);
    
    #define num 3
    #define x(y) num+y
    x(num);
}

billgan1024 avatar Sep 18 '23 18:09 billgan1024

@sean-mcmanus any update on this? btw I've seen the exact same issue with Visual Studio, and it was fixed very recently.

billgan1024 avatar Jan 31 '24 19:01 billgan1024

@billgan1024 we share this code with Visual Studio, so that fix should flow into our extension the next time we take a merge. It won't be in 1.19 though because we're stabilizing for release. I expect it will be in 1.20.0. We could do a pre-release not long after 1.19 releases to stable.

bobbrow avatar Jan 31 '24 20:01 bobbrow

@billgan1024 This is fixed in our 1.20.x pre-release channel.

sean-mcmanus avatar Apr 30 '24 18:04 sean-mcmanus