File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
src/PowerShellEditorServices/Workspace Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 1212using System . Text ;
1313using System . Runtime . InteropServices ;
1414using Microsoft . Extensions . FileSystemGlobbing ;
15- using Microsoft . Extensions . FileSystemGlobbing . Abstractions ;
1615
1716namespace Microsoft . PowerShell . EditorServices
1817{
@@ -49,6 +48,13 @@ public class Workspace
4948 "**/*"
5049 } ;
5150
51+ private static readonly string [ ] s_supportedUriSchemes = new [ ]
52+ {
53+ "file" ,
54+ "untitled" ,
55+ "inmemory"
56+ } ;
57+
5258 private ILogger logger ;
5359 private Version powerShellVersion ;
5460 private Dictionary < string , ScriptFile > workspaceFiles = new Dictionary < string , ScriptFile > ( ) ;
@@ -174,6 +180,20 @@ public ScriptFile GetFile(string filePath)
174180 /// <param name="scriptFile">The out parameter that will contain the ScriptFile object.</param>
175181 public bool TryGetFile ( string filePath , out ScriptFile scriptFile )
176182 {
183+ try
184+ {
185+ if ( filePath . Contains ( ":/" ) // Quick heuristic to determine if we might have a URI
186+ && ! s_supportedUriSchemes . Contains ( new Uri ( filePath ) . Scheme ) )
187+ {
188+ scriptFile = null ;
189+ return false ;
190+ }
191+ }
192+ catch
193+ {
194+ // If something goes wrong trying to check for URIs, just proceed to normal logic
195+ }
196+
177197 try
178198 {
179199 scriptFile = GetFile ( filePath ) ;
You can’t perform that action at this time.
0 commit comments