Skip to content

Commit 13f2107

Browse files
authored
Fix crash for finding symbols on bad paths (#749)
1 parent 8bf5c9c commit 13f2107

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/PowerShellEditorServices/Language/LanguageService.cs

+8-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using System.Management.Automation;
1414
using System.Management.Automation.Language;
1515
using System.Runtime.InteropServices;
16+
using System.Security;
1617
using System.Threading;
1718
using System.Threading.Tasks;
1819

@@ -346,9 +347,14 @@ public async Task<FindReferencesResult> FindReferencesOfSymbol(
346347
{
347348
scriptFile = workspace.GetFile(file);
348349
}
349-
catch (IOException)
350+
catch (Exception e) when (e is IOException
351+
|| e is SecurityException
352+
|| e is FileNotFoundException
353+
|| e is DirectoryNotFoundException
354+
|| e is PathTooLongException
355+
|| e is UnauthorizedAccessException)
350356
{
351-
// If the file has ceased to exist for some reason, we just skip it
357+
// If we can't access the file for some reason, just ignore it
352358
continue;
353359
}
354360

0 commit comments

Comments
 (0)