diff --git a/src/PowerShellEditorServices/Workspace/ScriptFile.cs b/src/PowerShellEditorServices/Workspace/ScriptFile.cs index a81200887..dab2918cc 100644 --- a/src/PowerShellEditorServices/Workspace/ScriptFile.cs +++ b/src/PowerShellEditorServices/Workspace/ScriptFile.cs @@ -648,7 +648,16 @@ private void ParseFileContents() .Select(ScriptFileMarker.FromParseError) .ToArray(); - //Get all dot sourced referenced files and store them + // Untitled files have no directory + // Discussed in https://github.com/PowerShell/PowerShellEditorServices/pull/815. + // Rather than working hard to enable things for untitled files like a phantom directory, + // users should save the file. + if (IsUntitledPath(this.FilePath)) + { + return; + } + + // Get all dot sourced referenced files and store them this.ReferencedFiles = AstOperations.FindDotSourcedIncludes(this.ScriptAst, Path.GetDirectoryName(this.FilePath)); }