diff --git a/grammars/csharp.tmLanguage b/grammars/csharp.tmLanguage index e0ea7e9..d2588e7 100644 --- a/grammars/csharp.tmLanguage +++ b/grammars/csharp.tmLanguage @@ -4029,7 +4029,7 @@ name meta.interpolation.cs begin - (?<=[^\{])((?:\{\{)*)(\{)(?=[^\{]) + (?<=[^\{]|^)((?:\{\{)*)(\{)(?=[^\{]) beginCaptures 1 diff --git a/grammars/csharp.tmLanguage.cson b/grammars/csharp.tmLanguage.cson index da04d15..381207c 100644 --- a/grammars/csharp.tmLanguage.cson +++ b/grammars/csharp.tmLanguage.cson @@ -2441,7 +2441,7 @@ repository: ] interpolation: name: "meta.interpolation.cs" - begin: "(?<=[^\\{])((?:\\{\\{)*)(\\{)(?=[^\\{])" + begin: "(?<=[^\\{]|^)((?:\\{\\{)*)(\\{)(?=[^\\{])" beginCaptures: "1": name: "string.quoted.double.cs" diff --git a/src/csharp.tmLanguage.yml b/src/csharp.tmLanguage.yml index 7d84a0f..4fd9673 100644 --- a/src/csharp.tmLanguage.yml +++ b/src/csharp.tmLanguage.yml @@ -1525,7 +1525,7 @@ repository: interpolation: name: meta.interpolation.cs - begin: (?<=[^\{])((?:\{\{)*)(\{)(?=[^\{]) + begin: (?<=[^\{]|^)((?:\{\{)*)(\{)(?=[^\{]) beginCaptures: '1': { name: string.quoted.double.cs } '2': { name: punctuation.definition.interpolation.begin.cs } diff --git a/test/interpolated-string.tests.ts b/test/interpolated-string.tests.ts index 0760b39..d7c9109 100644 --- a/test/interpolated-string.tests.ts +++ b/test/interpolated-string.tests.ts @@ -200,6 +200,29 @@ world {two}!";`); Token.Punctuation.Semicolon]); }); + it("break across two lines and start with a new line with an interpolation (verbatim)", async () => { + const input = Input.InClass(` +string test = $@" +I am a multiline string with a +{parameter} that starts after a newline! +";`); + const tokens = await tokenize(input); + + tokens.should.deep.equal([ + Token.PrimitiveType.String, + Token.Identifiers.FieldName("test"), + Token.Operators.Assignment, + Token.Punctuation.InterpolatedString.VerbatimBegin, + Token.Literals.String("I am a multiline string with a"), + Token.Punctuation.Interpolation.Begin, + Token.Variables.ReadWrite("parameter"), + Token.Punctuation.Interpolation.End, + Token.Literals.String(" that starts after a newline!"), + Token.Punctuation.InterpolatedString.End, + Token.Punctuation.Semicolon + ]); + }); + it("break across two lines with no interpolations (verbatim)", async () => { const input = Input.InClass(` diff --git a/test/literals.tests.ts b/test/literals.tests.ts index cae8747..0362ad1 100644 --- a/test/literals.tests.ts +++ b/test/literals.tests.ts @@ -526,4 +526,4 @@ namespace X }); }); }); -}); \ No newline at end of file +});