Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix references on Windows due to bad WorkspacePath #1110

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/PowerShellEditorServices/Server/PsesLanguageServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ public async Task StartAsync()
var workspaceService = serviceProvider.GetService<WorkspaceService>();

// Grab the workspace path from the parameters
workspaceService.WorkspacePath = request.RootUri?.LocalPath;
if (request.RootUri != null)
{
workspaceService.WorkspacePath = workspaceService.ResolveFilePath(request.RootUri.ToString());
}

// Set the working directory of the PowerShell session to the workspace path
if (workspaceService.WorkspacePath != null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public CodeLens ResolveCodeLens(CodeLens codeLens, ScriptFile scriptFile)
var acc = new List<Location>();
foreach (SymbolReference foundReference in referencesResult)
{
if (!NotReferenceDefinition(foundSymbol, foundReference))
if (IsReferenceDefinition(foundSymbol, foundReference))
{
continue;
}
Expand Down Expand Up @@ -144,12 +144,13 @@ public CodeLens ResolveCodeLens(CodeLens codeLens, ScriptFile scriptFile)
/// <param name="definition">The symbol definition that may be referenced.</param>
/// <param name="reference">The reference symbol to check.</param>
/// <returns>True if the reference is not a reference to the definition, false otherwise.</returns>
private static bool NotReferenceDefinition(
private static bool IsReferenceDefinition(
SymbolReference definition,
SymbolReference reference)
{
return
definition.ScriptRegion.StartLineNumber != reference.ScriptRegion.StartLineNumber
definition.FilePath != reference.FilePath
|| definition.ScriptRegion.StartLineNumber != reference.ScriptRegion.StartLineNumber
|| definition.SymbolType != reference.SymbolType
|| !string.Equals(definition.SymbolName, reference.SymbolName, StringComparison.OrdinalIgnoreCase);
}
Expand Down