Skip to content

Commit 77922a4

Browse files
Fix references on Windows due to bad WorkspacePath (#1110)
1 parent 085548f commit 77922a4

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/PowerShellEditorServices/Server/PsesLanguageServer.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ public async Task StartAsync()
111111
var workspaceService = serviceProvider.GetService<WorkspaceService>();
112112

113113
// Grab the workspace path from the parameters
114-
workspaceService.WorkspacePath = request.RootUri?.LocalPath;
114+
if (request.RootUri != null)
115+
{
116+
workspaceService.WorkspacePath = workspaceService.ResolveFilePath(request.RootUri.ToString());
117+
}
115118

116119
// Set the working directory of the PowerShell session to the workspace path
117120
if (workspaceService.WorkspacePath != null

src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public CodeLens ResolveCodeLens(CodeLens codeLens, ScriptFile scriptFile)
106106
var acc = new List<Location>();
107107
foreach (SymbolReference foundReference in referencesResult)
108108
{
109-
if (!NotReferenceDefinition(foundSymbol, foundReference))
109+
if (IsReferenceDefinition(foundSymbol, foundReference))
110110
{
111111
continue;
112112
}
@@ -144,12 +144,13 @@ public CodeLens ResolveCodeLens(CodeLens codeLens, ScriptFile scriptFile)
144144
/// <param name="definition">The symbol definition that may be referenced.</param>
145145
/// <param name="reference">The reference symbol to check.</param>
146146
/// <returns>True if the reference is not a reference to the definition, false otherwise.</returns>
147-
private static bool NotReferenceDefinition(
147+
private static bool IsReferenceDefinition(
148148
SymbolReference definition,
149149
SymbolReference reference)
150150
{
151151
return
152-
definition.ScriptRegion.StartLineNumber != reference.ScriptRegion.StartLineNumber
152+
definition.FilePath != reference.FilePath
153+
|| definition.ScriptRegion.StartLineNumber != reference.ScriptRegion.StartLineNumber
153154
|| definition.SymbolType != reference.SymbolType
154155
|| !string.Equals(definition.SymbolName, reference.SymbolName, StringComparison.OrdinalIgnoreCase);
155156
}

0 commit comments

Comments
 (0)