Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ syntax highlighting falls apart after specific struct syntax #652

Closed
1 task done
alexr00 opened this issue Jan 15, 2024 · 1 comment
Closed
1 task done

C++ syntax highlighting falls apart after specific struct syntax #652

alexr00 opened this issue Jan 15, 2024 · 1 comment
Labels
High Priority Common or breaks highlighting of more than just itself

Comments

@alexr00
Copy link

alexr00 commented Jan 15, 2024

Checklist

  • This problem exists even with the setting "C_Cpp.enhancedColorization": "Disabled"

If Disabling that^ makes the problem go away, then follow this to make an issue on the C++ extension:
https://github.com/microsoft/vscode-cpptools/issues/new/choose

The code with a problem is:

struct foo
{
	void (*bar1)() noexcept;
	void (*bar2)() noexcept;
	void (*bar3)() noexcept;
};

void baz()
{
	static_assert(false, "some string");
	int x = 0;
}

It looks like:

In latest insiders with the default theme
image

More issues are apparent depending on the theme being used
image

It should look like:

Here's the snippet again with some of the issues annotated. It appears as though the parser gets confused on the first function pointer and essentially thinks all the things after it are parameters in the function pointer type.

struct foo
{
    void (*bar1)() noexcept;        // noexcept is entity.name.type.parameter, should be storage.modifier.special.functional.post-parameters.noexcept.cpp
    void (*bar2)() noexcept;        // bar2 is variable.parameter.pointer.function, should be variable.other.pointer.function.cpp
    void (*bar3)() noexcept;
};                                  // } is meta.parameter.cpp, should be punctuationsection.block.end.bracket.curly.struct.cpp

void baz()                          // baz is entity.name.type.parameter.cpp, should be entity.name.function.definition.cpp
{
    static_assert(false, "string");
    int x = 0;                      // line is string.quoted.double.cpp
}

Originally from @akbyrd in microsoft/vscode#202365

@jeff-hykin jeff-hykin added the High Priority Common or breaks highlighting of more than just itself label Jan 16, 2024
@jeff-hykin
Copy link
Owner

@akbyrd thank you for including the scopes, that's super helpful. I think you're right, something is confusing the function pointer pattern and then it never closes. I bet it'll be an easy fix so I'll take a look when I get the chance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
High Priority Common or breaks highlighting of more than just itself
Projects
None yet
Development

No branches or pull requests

2 participants