better-cpp-syntax icon indicating copy to clipboard operation
better-cpp-syntax copied to clipboard

Suggestion: add textmate scope info to distinguish between integers and reals

Open xaxazak opened this issue 4 years ago • 2 comments

Originally requested here: https://github.com/microsoft/vscode-cpptools/issues/6700.

I suggest adding scopes to disambiguate between integers and reals, such as (in vscode, at least):

  • constant.numeric.decimal.cpp.integer
  • constant.numeric.decimal.cpp.real

Allowing different highlighting for integers and reals can help to avoid type-mismatch issues.

xaxazak avatar Dec 23 '20 11:12 xaxazak

Could you give some code examples of the difference? I don't think integers will have the decimal tag

jeff-hykin avatar Dec 25 '20 19:12 jeff-hykin

I'm not very familiar with these issues - I'm new to VSCode - so you may need to interpret my intent.

Using the VSCode command "Developer: Inspect Editor Tokens and Scopes" I get "constant.numeric.decimal.cpp" as the first entry for both "10" and "10.5" (although the decimal point gets "constant.numeric.decimal.point.cpp".

I think the decimal tag is for disambiguating the radix - decimal vs hexidecimal etc. At least, "0x10" gets "constant.numeric.hexadecimal.cpp".

So I guess you'd need versions for every combination of base and integer-vs-floating. Being able to distinguish exponent-containing floats would also be a nice-to-have although not very important.

xaxazak avatar Dec 25 '20 23:12 xaxazak