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

Fix Regex features in raw-string-literals. #65838

Merged
merged 4 commits into from
Dec 8, 2022

Conversation

CyrusNajmabadi
Copy link
Member

Fixes #65836

void Goo()
{
var r = new Regex("""
$$ (a)\0\1
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this previously would crash in highlight refs.

{
void goo()
{
var r = new Regex("""$$ """);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this case would previously assert, but not crash.

// that is relevant is the \ character, and it's only relevant if we insert into
// a normal string and not a verbatim string. There are no other regex characters
// that completion will produce that need any escaping.
Debug.Assert(token.Kind() == SyntaxKind.StringLiteralToken);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bogus assert.

// Characters can be discontiguous (for example, in multi-line-raw-string literals). So if the
// position is in one of the gaps, it won't be able to find a corresponding virtual char.
if (index < 0)
return null;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actual crash fix.

@CyrusNajmabadi CyrusNajmabadi merged commit 85712db into dotnet:main Dec 8, 2022
@CyrusNajmabadi CyrusNajmabadi deleted the rawRegex branch December 8, 2022 16:28
@ghost ghost added this to the Next milestone Dec 8, 2022
@Cosifne Cosifne modified the milestones: Next, 17.5 P3 Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RegexDocumentHighlighter.GetReferences throws when editing regex inside a raw string
3 participants