diff --git a/syntaxes/csharp.tmLanguage.yml b/syntaxes/csharp.tmLanguage.yml index 7406461a2..89159352b 100644 --- a/syntaxes/csharp.tmLanguage.yml +++ b/syntaxes/csharp.tmLanguage.yml @@ -478,7 +478,7 @@ repository: - include: '#type' - include: '#punctuation-accessor' '5': { name: entity.name.variable.property.cs } - end: (?=\}|;) + end: (?<=\})|(?=;) patterns: - include: '#comment' - include: '#property-accessors' @@ -517,7 +517,7 @@ repository: - include: '#punctuation-accessor' '5': name: keyword.other.this.cs - end: (?=\}|;) + end: (?<=\})|(?=;) patterns: - include: '#comment' - include: '#bracketed-parameter-list' @@ -562,7 +562,7 @@ repository: - name: entity.name.variable.event.cs match: '[_$[:alpha:]][_$[:alnum:]]*' - include: '#punctuation-comma' - end: (?=\}|;) + end: (?<=\})|(?=;) patterns: - include: '#comment' - include: '#event-accessors' @@ -631,7 +631,7 @@ repository: - include: '#type' - include: '#punctuation-accessor' '5': { name: entity.name.function.cs } - end: (?=\}|;) + end: (?<=\})|(?=;) patterns: - include: '#comment' - include: '#parenthesized-parameter-list' @@ -643,7 +643,7 @@ repository: begin: ([_$[:alpha:]][_$[:alnum:]]*)\s*(?=\() beginCaptures: '1': { name: entity.name.function.cs } - end: (?=\}|;) + end: (?<=\})|(?=;) patterns: - include: '#comment' - include: '#parenthesized-parameter-list' @@ -666,7 +666,7 @@ repository: beginCaptures: '1': { name: punctuation.tilde.cs } '2': { name: entity.name.function.cs } - end: (?=\}|;) + end: (?<=\})|(?=;) patterns: - include: '#comment' - include: '#parenthesized-parameter-list' @@ -698,7 +698,7 @@ repository: # '2': ? is a sub-expression. It's final value is not considered. '3': { name: keyword.other.operator.cs } '4': { name: entity.name.function.cs } - end: (?=\}|;) + end: (?<=\})|(?=;) patterns: - include: '#comment' - include: '#parenthesized-parameter-list' @@ -736,7 +736,7 @@ repository: '3': patterns: - include: '#type' - end: (?=\}|;) + end: (?<=\})|(?=;) patterns: - include: '#comment' - include: '#parenthesized-parameter-list' diff --git a/test/syntaxes/methods.test.syntax.ts b/test/syntaxes/methods.test.syntax.ts index 6699408c6..c37890a44 100644 --- a/test/syntaxes/methods.test.syntax.ts +++ b/test/syntaxes/methods.test.syntax.ts @@ -387,5 +387,41 @@ namespace Test Token.Punctuation.CloseBrace ]); }); + + it("shadowed methods are highlighted properly (issue #1084)", () => { + + const input = Input.InClass(` +private new void foo1() //Correct highlight +{ +} + +new void foo2() //Function name not highlighted +{ +} +`); + const tokens = tokenize(input); + + tokens.should.deep.equal([ + Token.Keywords.Modifiers.Private, + Token.Keywords.Modifiers.New, + Token.Type("void"), + Token.Identifiers.MethodName("foo1"), + Token.Punctuation.OpenParen, + Token.Punctuation.CloseParen, + Token.Comment.SingleLine.Start, + Token.Comment.SingleLine.Text("Correct highlight"), + Token.Punctuation.OpenBrace, + Token.Punctuation.CloseBrace, + Token.Keywords.Modifiers.New, + Token.Type("void"), + Token.Identifiers.MethodName("foo2"), + Token.Punctuation.OpenParen, + Token.Punctuation.CloseParen, + Token.Comment.SingleLine.Start, + Token.Comment.SingleLine.Text("Function name not highlighted"), + Token.Punctuation.OpenBrace, + Token.Punctuation.CloseBrace + ]); + }); }); }); \ No newline at end of file