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

Unrecognized literal string suffixes #610

Closed
1 task done
j-cortial opened this issue Oct 29, 2022 · 5 comments
Closed
1 task done

Unrecognized literal string suffixes #610

j-cortial opened this issue Oct 29, 2022 · 5 comments

Comments

@j-cortial
Copy link
Collaborator

Checklist

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

The code with a problem is:

#include <string>
#include <string_view>

using namespace std::literals::string_view_literals;
using namespace std::literals::string_literals;

const auto view = "Hello"sv;
const auto owned = "Hello"s;

It looks like:

string_suffix

It should look like:

The suffixes "s" and "sv" should be highlighted.

Reference

https://en.cppreference.com/w/cpp/language/user_literal

@j-cortial
Copy link
Collaborator Author

Numeric user-defined literal suffixes are already covered, but not suffixes for strings and characters.
I am currently working on a PR to fix that.

All literal suffixes are "user-defined", even the ones provided by the standard library. However, the suffixes that do not start with an underscore are reserved for use by the standard library (such as std::string operator""s), and they should not be defined in a program.

By the way, I think the tag used for numeric literal suffixes (keyword.other.unit.user-defined) could be improved, since there no intrinsic notion of unit (except in some special cases, for std::chrono for instance) for literals in general.
I would rather suggest keyword.other.suffix.user-defined.numeric (and keyword.other.suffix.user-defined.reserved.numeric for those not starting with an underscore) for instance.
The same remark applies to language-defined suffixes such as keyword.other.unit.suffix.floating-point and friends, since they specify a type, not a unit.

@j-cortial j-cortial mentioned this issue Nov 2, 2022
jeff-hykin added a commit to j-cortial/better-cpp-syntax that referenced this issue Dec 10, 2022
jeff-hykin added a commit that referenced this issue Dec 10, 2022
@jeff-hykin
Copy link
Owner

Sadly the keyword.other.unit is not done because it is accurate, but because keyword.other.unit is used by other languages and themes, while inventing a new scope means absolutely no existing theme is going to highlight it.

Ex: CSS highlighting
Screen Shot 2022-12-10 at 6 24 04 PM

However we can do both; "keyword.other.unit keyword.other.suffix.user-defined.numeric" will let it default to the keyword.other.unit color, but be overridden for super-customized themes that actually know about the existance of keyword.other.suffix.user-defined.numeric

@j-cortial
Copy link
Collaborator Author

My proposal in the PR: #622

jeff-hykin added a commit that referenced this issue Jan 15, 2023
Make suffix tags more consistent
@jeff-hykin
Copy link
Owner

published with v1.17.3! thanks for handling this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants