jeff-hykin / better-cpp-syntax

💾 The source of VS Code's C++ syntax highlighting
GNU General Public License v3.0
155 stars 30 forks source link

C++/CLI syntax highlighting messed up by attributes. #607

Closed sonicfly closed 4 months ago

sonicfly commented 2 years ago

Checklist

The code with a problem is:

    [LinuxExcluded]
    [Description("For testing")]
    public ref class TestClass
    ...

It looks like:

Screen Shot 2022-10-13 at 13 50 49 Screen Shot 2022-10-13 at 13 51 50

It should look like:

It should looks like the second screenshot. Seems the C++/CLI attributes will mess up the quotation detection and everything becomes red color after. And also single attribute seems OK (as the second screenshot shows). This issue doesn't happen if I disable the better-cpp-syntax plugin, but irrelevant to C_Cpp.enhancedColorization setting. And this issue shows up recently, not sure it is caused by VSCode or better-cpp-syntax plugin update, but I don't remember having this issue before.

jeff-hykin commented 2 years ago

Thats strange if its a recent change, but disabling the extension means it probably is. The color issue is happening because [LinuxExcluded] looks like the start of a lambda.

I didn't know attributes could start with only a single bracket. Is there a link to the specification so I can make sure to cover all the syntax cases? Something like:

Screen Shot 2022-10-27 at 6 00 14 PM
jeff-hykin commented 4 months ago

(not fixed but also I never found a reference to single-bracket attributes)