@@ -91,8 +91,9 @@ public ScriptFile CreateScriptFileFromFileBuffer(string filePath, string initial
91
91
}
92
92
93
93
/// <summary>
94
- /// Gets an open file in the workspace. If the file isn't open but
95
- /// exists on the filesystem, load and return it.
94
+ /// Gets an open file in the workspace. If the file isn't open but exists on the filesystem, load and return it.
95
+ /// <para>IMPORTANT: Not all documents have a backing file e.g. untitled: scheme documents. Consider using
96
+ /// <see cref="Workspace.TryGetFile(string, out ScriptFile)"/> instead.</para>
96
97
/// </summary>
97
98
/// <param name="filePath">The file path at which the script resides.</param>
98
99
/// <exception cref="FileNotFoundException">
@@ -109,11 +110,9 @@ public ScriptFile GetFile(string filePath)
109
110
string resolvedFilePath = this . ResolveFilePath ( filePath ) ;
110
111
string keyName = resolvedFilePath . ToLower ( ) ;
111
112
112
- // Make sure the file isn't already loaded into the workspace and that the filePath isn't an "in-memory" path.
113
- // There have been crashes caused by this method being called with an "untitled:" document uri. See:
114
- // https://github.com/PowerShell/vscode-powershell/issues/1676
113
+ // Make sure the file isn't already loaded into the workspace
115
114
ScriptFile scriptFile = null ;
116
- if ( ! this . workspaceFiles . TryGetValue ( keyName , out scriptFile ) && ! IsPathInMemory ( filePath ) )
115
+ if ( ! this . workspaceFiles . TryGetValue ( keyName , out scriptFile ) )
117
116
{
118
117
// This method allows FileNotFoundException to bubble up
119
118
// if the file isn't found.
@@ -156,9 +155,7 @@ e is DirectoryNotFoundException ||
156
155
e is PathTooLongException ||
157
156
e is UnauthorizedAccessException )
158
157
{
159
- this . logger . WriteException (
160
- $ "Failed to set breakpoint on file: { filePath } ",
161
- e ) ;
158
+ this . logger . WriteHandledException ( $ "Failed to get file for { nameof ( filePath ) } : '{ filePath } '", e ) ;
162
159
scriptFile = null ;
163
160
return false ;
164
161
}
0 commit comments