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

"Highlighting Escape Sequence" doesn't handle C/C++'s "#include" file names and raw string literals correctly. #11

Open
EFanZh opened this issue Dec 14, 2013 · 9 comments
Labels

Comments

@EFanZh
Copy link

EFanZh commented Dec 14, 2013

For example, in the following code:

#include <abc\def.h>

"\d" isn't an escape sequence.

Also, the raw string literals are not handled correctly, like this:

R"(abc\def)"
@tomasr
Copy link
Owner

tomasr commented Dec 18, 2013

Great catch. Not quite sure how to fix it, yet, as it would require checking if the previous classification span was a preprocessor directive, and want to make sure the check doesn't impact performance negatively.

tomasr added a commit that referenced this issue Dec 21, 2013
@fdncred
Copy link

fdncred commented Feb 24, 2017

I guess this is the same type error but in F#/C#. The \123 is colored incorrectly.

let newLines = System.IO.File.ReadAllLines(@"c:\users\12345678\desktopsmall-new.txt") |> Array.toList

@tomasr
Copy link
Owner

tomasr commented Feb 24, 2017

@fdncred I did not know F# supported @ strings, so that's definitely a bug. I'll fix that one.

However, I would not expect this to be an issue in C#, are you seeing it happening there as well?

@fdncred
Copy link

fdncred commented Feb 24, 2017

You are correct, sir. This error does not show up in C#.

@chasingcode
Copy link

There seems to be a bug when interpolated and verbatim symbols are both used for the same string in C#. Although the character after the backslash is not escaped, the coloring suggests it is:
private string Test1 => $@"{foo}\bar";

In this screenshot, Test1 is incorrectly colored, but Test2 and Test3 are correct.

Visual Studio 2017 v15.2 (26430.12)
Viasfora v3.5.139

@tomasr
Copy link
Owner

tomasr commented Jun 2, 2017

@chasingcode Created a separate issue to track this one. Thanks for reporting, interpolated strings give me headaches!

@chasingcode
Copy link

Thank you for the quick response and making such a helpful extension! It's much appreciated

@fdncred
Copy link

fdncred commented Aug 6, 2018

@tomasr - Are you still working on proper highlighting for include files in C++? It's pretty annoying.

@schmerg
Copy link

schmerg commented Sep 25, 2024

Raw string literals that span multiple lines in C++11 are not just not highlighted correctly, but seem to break the brace matching logic so

{
  auto s = R"(    some string with "quotes" using raw string literals    )";
  ...

will show correctly but

{
  auto s = R"(    some string with "quotes" 
and newlines
using raw string literals    )";
  ...

will try to match the close brace of the literal with the curly brace of the enclosing block and so highlight it as incorrect (and mess up the colouring of matched braces etc thereafter)

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

No branches or pull requests

5 participants