diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/PsesSemanticTokensHandler.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/PsesSemanticTokensHandler.cs index a5a520783..4d2d2870b 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/PsesSemanticTokensHandler.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/PsesSemanticTokensHandler.cs @@ -123,9 +123,10 @@ private static SemanticTokenType MapSemanticTokenType(Token token) return SemanticTokenType.Type; } + // This represents keys in hashtables and also properties like `Foo` in `$myVar.Foo` if ((token.TokenFlags & TokenFlags.MemberName) != 0) { - return SemanticTokenType.Member; + return SemanticTokenType.Property; } // Only check token kind after checking flags diff --git a/test/PowerShellEditorServices.Test/Language/SemanticTokenTest.cs b/test/PowerShellEditorServices.Test/Language/SemanticTokenTest.cs index 3dbd66e7d..7d074557d 100644 --- a/test/PowerShellEditorServices.Test/Language/SemanticTokenTest.cs +++ b/test/PowerShellEditorServices.Test/Language/SemanticTokenTest.cs @@ -113,7 +113,7 @@ function Get-A*A { } [Fact] - public async Task RecognizesArrayMemberInExpandableString() + public async Task RecognizesArrayPropertyInExpandableString() { string text = "\"$(@($Array).Count) OtherText\""; ScriptFile scriptFile = new ScriptFile( @@ -131,7 +131,7 @@ public async Task RecognizesArrayMemberInExpandableString() Assert.Single(mappedTokens, sToken => SemanticTokenType.Variable == sToken.Type); break; case "Count": - Assert.Single(mappedTokens, sToken => SemanticTokenType.Member == sToken.Type); + Assert.Single(mappedTokens, sToken => SemanticTokenType.Property == sToken.Type); break; } } @@ -179,7 +179,7 @@ enum MyEnum{ case "one": case "two": case "three": - Assert.Single(mappedTokens, sToken => SemanticTokenType.Member == sToken.Type); + Assert.Single(mappedTokens, sToken => SemanticTokenType.Property == sToken.Type); break; } }