-
Notifications
You must be signed in to change notification settings - Fork 28
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
Incorrect highlighting with C/C++ when macro call does not end in semicolon #311
Comments
Even GitHub's syntax highlighting is broken lol |
Teamwork makes the dream work. |
WTF. I can't reproduce on my Linux system. The above screenshot is from my mac. @matter123 I will get back to you tomorrow with the mac confirmation. Otherwise VSCode screwed me again. |
Thanks for saying its mac specific. I'll confirm in a few minutes. Edit: I am unable to reproduce.
|
Based on the color of the macro arguments. I am guessing that some code earlier in the file is the actual issue. If you can reproduce, the full scope for |
Sounds good. Thanks @matter123 |
I think this could be coming from the C++ extension. Trying to reproduce with all other extensions off will probably fix the OS-dependent differences. If it doesn't I really have no idea what is going on. If the semicolon affects the validity of the code, that would affect the C++ extension's ability to add the additional highlighting. Right now the TextMate grammar is able to handle lots of wouldn't-compile code, but the C++ extension has a hard time with it. |
@jeff-hykin that was a really good point. I turned on the enhanced highlighting with the last release of the C/C++ extension. Then I think this can be closed in favor of me opening another issue with that repository. Thanks for the debugging help. It may help if you add a snippet to the issue template that people should check the syntax highlighting with "C_cpp.enhancedColorization" to "Disabled" to confirm that it is an issue with this extension. |
@matter123 I don't want to spam another issue. Can you check the textmate scopes on these function pointers that GCC compiler extension attributes associated with them? They seem to lose their function pointer scope when the attributes are applied. struct _HarvestRequestClass
{
GObjectClass parent_class;
const char *(*G_GNUC_CONST G_GNUC_WARN_UNUSED_RESULT serialize_params)(HarvestRequest *self);
const char *(*G_GNUC_CONST get_endpoint)(HarvestRequest *self);
}; |
That is what I figured. Thank you for the information! |
G_GNU_[A-Z_]+ seems fairly common and mostly used for attributes. Maybe consider opening a new issue for that. https://github.com/search?p=2&q=G_GNUC_&type=Code&utf8=%E2%9C%93 |
It is a GLib thing. I am not totally convinced that you guys should start making exceptions in the grammar. I am noticing weird behavior on the last comma in the macro definition, or maybe the previous two commas are wrong. Is TRUE supposed to be recognized as a boolean value in this context? #define HARVEST_REQUEST_PARAM_APPEND(string, key, value, edited, ampersand) \
do { \
(if (edited) { \
if (ampersand) { \
g_string_append_printf(string, "&%s=%s", #key, #value); \
} else { \
ampersand = TRUE; \
g_string_append_printf(string, "%s=%s", #key, #value); \
} \
}) \
} while (0) |
So the comma issue is definitely a bug, the first 3 arguments are all one token. I don't think that Open a new issue for the comma. |
Will do |
I have reproduced this with C/C++ and on 1.12.20 and the default VSCode version.
Before semicolon
![image](https://user-images.githubusercontent.com/11936772/61247357-82f93500-a716-11e9-8d74-636d98eaf3a7.png)
After semicolon
![image](https://user-images.githubusercontent.com/11936772/61247390-95736e80-a716-11e9-8bb3-b74b69fa0073.png)
The text was updated successfully, but these errors were encountered: