diff --git a/src/PowerShellEditorServices/Workspace/Workspace.cs b/src/PowerShellEditorServices/Workspace/Workspace.cs index d74bf4955..6b31b094f 100644 --- a/src/PowerShellEditorServices/Workspace/Workspace.cs +++ b/src/PowerShellEditorServices/Workspace/Workspace.cs @@ -408,7 +408,6 @@ private void RecursivelyFindReferences( GetBaseFilePath( scriptFile.FilePath); - ScriptFile referencedFile; foreach (string referencedFileName in scriptFile.ReferencedFiles) { string resolvedScriptPath = @@ -429,12 +428,9 @@ private void RecursivelyFindReferences( referencedFileName, resolvedScriptPath)); - // Make sure file exists before trying to get the file - if (File.Exists(resolvedScriptPath)) + // Get the referenced file if it's not already in referencedScriptFiles + if (this.TryGetFile(resolvedScriptPath, out ScriptFile referencedFile)) { - // Get the referenced file if it's not already in referencedScriptFiles - referencedFile = this.GetFile(resolvedScriptPath); - // Normalize the resolved script path and add it to the // referenced files list if it isn't there already resolvedScriptPath = resolvedScriptPath.ToLower();