-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Improve highlighting consistency by special-casing common types #3234
Conversation
What does the |
Yeah it does represent 'type', but it is a POSIX convention that does not hold for C++. It does sort of hold for C (as per cppreference. Also C is often used in conjunction with POSIX system code where this is an explicit rule (see link in PR description). I guess it's a form of Hungarian notation that does make sense, yes, but also leads to many false positives for C++. Technically speaking the |
Yeah, this looks generally good to me. For consistency I would consider adding Also, what about the atomic typedefs from C? |
Yes I guess that makes sense. Then in the meantime the C++ implementation has better C-highlighting than the C implementation 😏
Yeah this makes sense as well. I will change the implementation to a regular expression like you suggested here before. |
Hey! I'm sorry for leaving this PR open for so long. I haven't had much time to work on it. Now I created an inventory of all the additional types that are considered special. I also added some extra test content to cover them. In the current implementation the additional types are in an array Can anyone help me to have this regular expression Any help is appreciated! Thanks in advance 😄 |
This isn't necessary, as compression will clean up much of the "wasted" space... and the readability aids future maintenance.
I'm still hoping to get another pair of eyeballs on this as I still worry about killing the generic
When we're thru here if you're willing to circle back and fix C that's be great... but now that they have diverged such is the possibility, that one will become better than the other... |
True, true, but I'm not sure it has any impact on the speed for instance. With the types added that Konrad suggested, it's quite a list now (92 items with a fair bit of partly overlapped words).
Well yeah another vote on how to handle this is a good idea. I feel, as a drive-by contributor, I should only provide advice about this matter. Personally I lean towards the treating-additional-types-special approach, but it's a trade-off between simplicity + some false positives vs. complexity + (IMHO) more correct (not 100%) highlighting.
Yes, I would like to do this. But due to summer holidays etc. etc. I won't be able to pick this up until late August probably. |
92 is not a large list - we have languages with thousands of keywords. There is no run-time performance impact when using the IF speed became a higher priority I would prefer we somehow do this type of conversion at build or compile time - rather than hard code it into the source, making the source much harder to work with. |
OK, I pushed the update of the additional type list for now and the extension of the tests to verify all of these. I hope someone else with a C++ background can chime in to discuss this PR! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@klmr @joshgoebel
Follows up #3178
Description
In the current version of the C++ highlighting set is a regular expression rule called
CPP_PRIMITIVE_TYPES
that highlights POSIX-defined special types. However, this does not hold for C++ and leads to false positives in highlighting. Especially the_t
convention for alias template helpers for type traits come to mind (e.g.std::decay_t<...>
et al).There is, however, a set of common language-defined types that for a large part have the
_t
suffix. These types should be highlighted and could be considered primitive types.In this PR I propose to change the regular expression to match suffix
_t
for any type to be changed to a list of selected types for highlighting. It is the intent for this list to remain as minimal as possible, perhaps this should be clarified in a comment.Changes
CPP_PRIMITIVE_TYPES
to a list of selected types for highlighting.Checklist
CHANGES.md