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 12
12
using System . Text ;
13
13
using System . Runtime . InteropServices ;
14
14
using Microsoft . Extensions . FileSystemGlobbing ;
15
- using Microsoft . Extensions . FileSystemGlobbing . Abstractions ;
16
15
17
16
namespace Microsoft . PowerShell . EditorServices
18
17
{
@@ -49,6 +48,13 @@ public class Workspace
49
48
"**/*"
50
49
} ;
51
50
51
+ private static readonly string [ ] s_supportedUriSchemes = new [ ]
52
+ {
53
+ "file" ,
54
+ "untitled" ,
55
+ "inmemory"
56
+ } ;
57
+
52
58
private ILogger logger ;
53
59
private Version powerShellVersion ;
54
60
private Dictionary < string , ScriptFile > workspaceFiles = new Dictionary < string , ScriptFile > ( ) ;
@@ -174,6 +180,20 @@ public ScriptFile GetFile(string filePath)
174
180
/// <param name="scriptFile">The out parameter that will contain the ScriptFile object.</param>
175
181
public bool TryGetFile ( string filePath , out ScriptFile scriptFile )
176
182
{
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
+
177
197
try
178
198
{
179
199
scriptFile = GetFile ( filePath ) ;
You can’t perform that action at this time.
0 commit comments