Skip to content

Commit

Permalink
Handle null case in ReferencesCodeLensProvider's CodeLens resolver
Browse files Browse the repository at this point in the history
This change fixes an issue where a null case isn't being handled
gracefully in the ReferencesCodeLensProvider when resolving a CodeLens
while the user is typing out a new function defintion or doing anything
else that causes the code to change like formatting the script.

Resolves PowerShell/vscode-powershell#857
Resolves PowerShell/vscode-powershell#855
  • Loading branch information
daviwil committed Jun 12, 2017
1 parent 6fa555a commit 0c1d459
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ await requestContext.SendResult(
}
else
{
// TODO: Write error!
await requestContext.SendError(
$"Could not find provider for the original CodeLens: {codeLensData.ProviderId}");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,18 @@ await editorSession.LanguageService.FindReferencesOfSymbol(
references,
editorSession.Workspace);

var referenceLocations =
referencesResult
.FoundReferences
.Select(
r => new Location
{
Uri = GetFileUri(r.FilePath),
Range = r.ScriptRegion.ToRange()
})
.ToArray();
Location[] referenceLocations =
referencesResult == null
? new Location[0]
: referencesResult
.FoundReferences
.Select(
r => new Location
{
Uri = GetFileUri(r.FilePath),
Range = r.ScriptRegion.ToRange()
})
.ToArray();

return
new CodeLens(
Expand Down

0 comments on commit 0c1d459

Please sign in to comment.