Skip to content

Fix signature handler regression #757

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 28, 2018
Merged
Changes from all commits
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
19 changes: 10 additions & 9 deletions src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -842,23 +842,24 @@ await editorSession.LanguageService.FindParameterSetsInFile(

if (parameterSets != null)
{
var sigs = new List<SignatureInformation>();
foreach (ParameterSetSignature sig in parameterSets.Signatures)
signatures = new SignatureInformation[parameterSets.Signatures.Length];
for (int i = 0; i < signatures.Length; i++)
{
var parameters = new List<ParameterInformation>();
foreach (ParameterInfo paramInfo in sig.Parameters)
var parameters = new ParameterInformation[parameterSets.Signatures[i].Parameters.Count()];
int j = 0;
foreach (ParameterInfo param in parameterSets.Signatures[i].Parameters)
Copy link
Member

Choose a reason for hiding this comment

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

Can you use another for loop here instead of foreach since you need the index j anyway?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had that first, but changed it back because the Parameters property is an IEnumerable - so it can't be indexed.

The foreach means we can iterate over it without extra effort.

{
parameters.Add(CreateParameterInfo(paramInfo));
parameters[j] = CreateParameterInfo(param);
j++;
}

var signature = new SignatureInformation
signatures[i] = new SignatureInformation
{
Label = parameterSets.CommandName + " " + sig.SignatureText,
Label = parameterSets.CommandName + " " + parameterSets.Signatures[i].SignatureText,
Documentation = null,
Parameters = parameters.ToArray(),
Parameters = parameters,
};
}
signatures = sigs.ToArray();
}

await requestContext.SendResult(
Expand Down