Skip to content

Commit 7c4b3b7

Browse files
author
Justin Chen
committed
addressed issues in PR
1 parent 09d632c commit 7c4b3b7

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

src/PowerShellEditorServices/Services/TextDocument/Handlers/PsesSemanticTokensHandler.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ internal class PsesSemanticTokensHandler : SemanticTokensHandler
3333
}),
3434
RangeProvider = true
3535
};
36+
3637
private readonly ILogger _logger;
3738
private readonly WorkspaceService _workspaceService;
3839

39-
public PsesSemanticTokensHandler(ILogger<PsesSemanticTokensHandler> logger, WorkspaceService workspaceService) : base(s_registrationOptions)
40+
public PsesSemanticTokensHandler(ILogger<PsesSemanticTokensHandler> logger, WorkspaceService workspaceService)
41+
: base(s_registrationOptions)
4042
{
4143
_logger = logger;
4244
_workspaceService = workspaceService;
@@ -59,7 +61,7 @@ private static void PushToken(Token token, SemanticTokensBuilder builder)
5961
{
6062
builder.Push(
6163
sToken.Line,
62-
sToken.Index,
64+
sToken.Column,
6365
length: sToken.Text.Length,
6466
sToken.Type,
6567
tokenModifiers: sToken.TokenModifiers);
@@ -88,12 +90,13 @@ internal static IEnumerable<SemanticToken> ConvertToSemanticTokens(Token token)
8890
yield break;
8991
}
9092

91-
//Tokens line and col numbers indexed starting from 1, expecting indexing from 0
92-
int line = token.Extent.StartLineNumber - 1;
93-
int index = token.Extent.StartColumnNumber - 1;
94-
SemanticToken sToken = new SemanticToken(token.Text, mappedType,
95-
line, index, Array.Empty<string>());
96-
yield return sToken;
93+
//Note that both column and line numbers are 0-based
94+
yield return new SemanticToken(
95+
token.Text,
96+
mappedType,
97+
line: token.Extent.StartLineNumber - 1,
98+
column: token.Extent.StartColumnNumber - 1,
99+
tokenModifiers: Array.Empty<string>());
97100
}
98101

99102
private static SemanticTokenType MapSemanticTokenType(Token token)

src/PowerShellEditorServices/Services/TextDocument/SemanticToken.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ namespace Microsoft.PowerShell.EditorServices.Services.TextDocument
55
{
66
internal class SemanticToken
77
{
8-
public SemanticToken(string text, SemanticTokenType type, int line, int index, IEnumerable<string> tokenModifiers)
8+
public SemanticToken(string text, SemanticTokenType type, int line, int column, IEnumerable<string> tokenModifiers)
99
{
1010
Line = line;
1111
Text = text;
12-
Index = index;
12+
Column = column;
1313
Type = type;
1414
TokenModifiers = tokenModifiers;
1515
}
1616

17-
public string Text {get; set;}
17+
public string Text { get; set ;}
1818

19-
public int Line {get; set;}
19+
public int Line { get; set; }
2020

21-
public int Index {get; set;}
21+
public int Column { get; set; }
2222

23-
public SemanticTokenType Type {get; set;}
23+
public SemanticTokenType Type { get; set; }
2424

25-
public IEnumerable<string> TokenModifiers {get; set;}
25+
public IEnumerable<string> TokenModifiers { get; set; }
2626
}
2727
}

0 commit comments

Comments
 (0)