From 65196dd25b6cef3c255dda5b8ca2046d16c777e2 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Tue, 19 Nov 2019 19:25:14 -0800 Subject: [PATCH] Fix references on Windows due to bad WorkspacePath --- src/PowerShellEditorServices/Server/PsesLanguageServer.cs | 5 ++++- .../Services/CodeLens/ReferencesCodeLensProvider.cs | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/PowerShellEditorServices/Server/PsesLanguageServer.cs b/src/PowerShellEditorServices/Server/PsesLanguageServer.cs index b454a190a..3daf3cd52 100644 --- a/src/PowerShellEditorServices/Server/PsesLanguageServer.cs +++ b/src/PowerShellEditorServices/Server/PsesLanguageServer.cs @@ -111,7 +111,10 @@ public async Task StartAsync() var workspaceService = serviceProvider.GetService(); // 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 diff --git a/src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs b/src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs index 1ef194a56..c8dfc72d8 100644 --- a/src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs +++ b/src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs @@ -106,7 +106,7 @@ public CodeLens ResolveCodeLens(CodeLens codeLens, ScriptFile scriptFile) var acc = new List(); foreach (SymbolReference foundReference in referencesResult) { - if (!NotReferenceDefinition(foundSymbol, foundReference)) + if (IsReferenceDefinition(foundSymbol, foundReference)) { continue; } @@ -144,12 +144,13 @@ public CodeLens ResolveCodeLens(CodeLens codeLens, ScriptFile scriptFile) /// The symbol definition that may be referenced. /// The reference symbol to check. /// True if the reference is not a reference to the definition, false otherwise. - 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); }