Skip to content

Commit 2e5bc40

Browse files
author
Kayla Davis
committed
Fix dot sourcing a non existant file bug
1 parent 633e36b commit 2e5bc40

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/PowerShellEditorServices/Session/Workspace.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,17 @@ private void RecursivelyFindReferences(
123123
scriptFile.FilePath,
124124
referencedFileName);
125125

126-
// Get the referenced file if it's not already in referencedScriptFiles
127-
referencedFile = this.GetFile(resolvedScriptPath);
128-
if (!referencedScriptFiles.ContainsKey(resolvedScriptPath))
126+
// make sure file exists before trying to get the file
127+
if (File.Exists(resolvedScriptPath))
129128
{
130-
referencedScriptFiles.Add(resolvedScriptPath, referencedFile);
131-
RecursivelyFindReferences(referencedFile, referencedScriptFiles);
129+
// Get the referenced file if it's not already in referencedScriptFiles
130+
referencedFile = this.GetFile(resolvedScriptPath);
131+
if (!referencedScriptFiles.ContainsKey(resolvedScriptPath))
132+
{
133+
referencedScriptFiles.Add(resolvedScriptPath, referencedFile);
134+
RecursivelyFindReferences(referencedFile, referencedScriptFiles);
135+
}
132136
}
133-
134-
135137
}
136138
}
137139

0 commit comments

Comments
 (0)