Skip to content

Fix crash for finding symbols on bad paths #749

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 20, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/PowerShellEditorServices/Language/LanguageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using System.Management.Automation;
using System.Management.Automation.Language;
using System.Runtime.InteropServices;
using System.Security;
using System.Threading;
using System.Threading.Tasks;

Expand Down Expand Up @@ -346,9 +347,13 @@ public async Task<FindReferencesResult> FindReferencesOfSymbol(
{
scriptFile = workspace.GetFile(file);
}
catch (IOException)
catch (Exception e) when (e is IOException
|| e is SecurityException
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does SecurityException include the "can't access due to permissions"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, I foolishly trusted that it did because the FileStream constructor docs only mention the exceptions I included here, but it looks like it doesn't >:(

|| e is FileNotFoundException
|| e is DirectoryNotFoundException
|| e is PathTooLongException)
{
// If the file has ceased to exist for some reason, we just skip it
// If we can't access the file for some reason, just ignore it
continue;
}

Expand Down