diff --git a/grammars/csharp.tmLanguage b/grammars/csharp.tmLanguage index e01cc11..2195f9f 100644 --- a/grammars/csharp.tmLanguage +++ b/grammars/csharp.tmLanguage @@ -6156,7 +6156,7 @@ name constant.character.escape.cs match - \\(['"\\0abfnrtv]|x[0-9a-fA-F]{1,4}|u[0-9a-fA-F]{4}) + \\(x[0-9a-fA-F]{1,4}|u[0-9a-fA-F]{4}|.) string-literal @@ -6200,7 +6200,7 @@ name constant.character.escape.cs match - \\(['"\\0abfnrtv]|x[0-9a-fA-F]{1,4}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}) + \\(x[0-9a-fA-F]{1,4}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|.) verbatim-string-literal diff --git a/grammars/csharp.tmLanguage.cson b/grammars/csharp.tmLanguage.cson index 81d141d..d8534ce 100644 --- a/grammars/csharp.tmLanguage.cson +++ b/grammars/csharp.tmLanguage.cson @@ -3705,7 +3705,7 @@ repository: ] "char-character-escape": name: "constant.character.escape.cs" - match: "\\\\(['\"\\\\0abfnrtv]|x[0-9a-fA-F]{1,4}|u[0-9a-fA-F]{4})" + match: "\\\\(x[0-9a-fA-F]{1,4}|u[0-9a-fA-F]{4}|.)" "string-literal": name: "string.quoted.double.cs" begin: "(? { Token.Punctuation.Semicolon]); }); + it("escaped character escape \\e", async () => { + const input = Input.InClass(`char x = '\\e';`); + const tokens = await tokenize(input); + + tokens.should.deep.equal([ + Token.PrimitiveType.Char, + Token.Identifier.FieldName("x"), + Token.Operator.Assignment, + Token.Punctuation.Char.Begin, + Token.Literal.CharacterEscape("\\e"), + Token.Punctuation.Char.End, + Token.Punctuation.Semicolon]); + }); + it("escaped character escape \\t", async () => { const input = Input.InClass(`char x = '\\t';`); const tokens = await tokenize(input); @@ -712,6 +726,22 @@ describe("Literals", () => { Token.Punctuation.Semicolon]); }); + it("escaped character escape \\e", async () => { + const input = Input.InClass(`string test = "hello\\eworld!";`); + const tokens = await tokenize(input); + + tokens.should.deep.equal([ + Token.PrimitiveType.String, + Token.Identifier.FieldName("test"), + Token.Operator.Assignment, + Token.Punctuation.String.Begin, + Token.Literal.String("hello"), + Token.Literal.CharacterEscape("\\e"), + Token.Literal.String("world!"), + Token.Punctuation.String.End, + Token.Punctuation.Semicolon]); + }); + it("escaped character escape \\n", async () => { const input = Input.InClass(`string test = "hello\\nworld!";`); const tokens = await tokenize(input);