File tree 1 file changed +21
-0
lines changed
src/PowerShellEditorServices/Workspace
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,13 @@ public class Workspace
29
29
"*.psd1"
30
30
} ;
31
31
32
+ private static readonly string [ ] s_supportedUriSchemes = new [ ]
33
+ {
34
+ "file" ,
35
+ "untitled" ,
36
+ "inmemory"
37
+ } ;
38
+
32
39
private ILogger logger ;
33
40
private Version powerShellVersion ;
34
41
private Dictionary < string , ScriptFile > workspaceFiles = new Dictionary < string , ScriptFile > ( ) ;
@@ -142,6 +149,20 @@ public ScriptFile GetFile(string filePath)
142
149
/// <param name="scriptFile">The out parameter that will contain the ScriptFile object.</param>
143
150
public bool TryGetFile ( string filePath , out ScriptFile scriptFile )
144
151
{
152
+ try
153
+ {
154
+ if ( filePath . Contains ( ":/" ) // Quick heuristic to determine if we might have a URI
155
+ && ! s_supportedUriSchemes . Contains ( new Uri ( filePath ) . Scheme ) )
156
+ {
157
+ scriptFile = null ;
158
+ return false ;
159
+ }
160
+ }
161
+ catch
162
+ {
163
+ // If something goes wrong trying to check for URIs, just proceed to normal logic
164
+ }
165
+
145
166
try
146
167
{
147
168
scriptFile = GetFile ( filePath ) ;
You can’t perform that action at this time.
0 commit comments