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 interpolated raw string literals breaking colorization #348

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Viasfora.Languages/BraceScanners/CSharpBraceScanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private bool ParseText(ITextChars tc, ref CharPos pos) {
this.multiLine = true;
tc.Skip(2);
this.ParseMultiLineString(tc);
} else if ( tc.Char() == '$' && tc.NChar() == '"' ) {
} else if ( tc.Char() == '$' && tc.NChar() == '"' && tc.NNChar() != '"') {
// Roslyn interpolated string
this.parsingExpression = false;
this.status = stIString;
Expand Down
9 changes: 9 additions & 0 deletions tests/Viasfora.Tests/BraceScanners/CSharpBraceScannerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,16 @@ public void RawString1() {
var extractor = new CSharpBraceScanner();
var chars = ExtractWithLines(extractor, input.Trim(), 0, 0);
Assert.Equal(0, chars.Count);
}

[Fact]
public void RawString2() {
String input = "($\"\"\"some \r\n string with \r\n{\"quotes\"} \"\"\")";
var extractor = new CSharpBraceScanner();
var chars = ExtractWithLines(extractor, input.Trim(), 0, 0);
Assert.Equal(2, chars.Count); // should be 4 when interpolation is supported
}

// TODO: Support later
/*
[Fact]
Expand Down