File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
src/PowerShellEditorServices/Workspace Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,13 @@ public class Workspace
2929 "*.psd1"
3030 } ;
3131
32+ private static readonly string [ ] s_supportedUriSchemes = new [ ]
33+ {
34+ "file" ,
35+ "untitled" ,
36+ "inmemory"
37+ } ;
38+
3239 private ILogger logger ;
3340 private Version powerShellVersion ;
3441 private Dictionary < string , ScriptFile > workspaceFiles = new Dictionary < string , ScriptFile > ( ) ;
@@ -142,6 +149,20 @@ public ScriptFile GetFile(string filePath)
142149 /// <param name="scriptFile">The out parameter that will contain the ScriptFile object.</param>
143150 public bool TryGetFile ( string filePath , out ScriptFile scriptFile )
144151 {
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+
145166 try
146167 {
147168 scriptFile = GetFile ( filePath ) ;
You can’t perform that action at this time.
0 commit comments