Skip to content
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

Return the SignatureHelp items nearest to the cursor #73606

Merged
merged 6 commits into from
May 24, 2024

Conversation

JoeRobich
Copy link
Member

@JoeRobich JoeRobich commented May 21, 2024

The LSP SignatureHelpHandler only ever considered the SignatureHelpItems returned from the first provider to give us items. This change moves us to considering all providers and returning the help items with the nearest applicable span.

fixes dotnet/vscode-csharp#6670

@JoeRobich JoeRobich requested a review from a team as a code owner May 21, 2024 00:26
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels May 21, 2024
@davidwengier
Copy link
Contributor

Oohh, this might fix dotnet/razor#6335 too ❤️

@JoeRobich
Copy link
Member Author

Oohh, this might fix dotnet/razor#6335 too ❤️

Maybe, a lot of things have changed since that issue was opened.

@@ -174,66 +176,6 @@ private static bool DisplayPartsMatch(SignatureHelpItem i1, SignatureHelpItem i2

private static bool CompareParts(TaggedText p1, TaggedText p2)
=> p1.ToString() == p2.ToString();

private static async Task<(ISignatureHelpProvider provider, SignatureHelpItems items)> ComputeItemsAsync(
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved into the SignatureHelpService.

Copy link
Member

Choose a reason for hiding this comment

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

i'm assuming it didn't change (beyond anything mechanical). if it did, please call that out.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will do a better job of this going forward. Added comments below.

@JoeRobich
Copy link
Member Author

@CyrusNajmabadi Ready for another review when you have time.

var extensionManager = document.Project.Solution.Services.GetRequiredService<IExtensionManager>();

ISignatureHelpProvider? bestProvider = null;
SignatureHelpItems? bestItems = null;
Copy link
Member

Choose a reason for hiding this comment

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

i'm assuming this was a move, and didn't change.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, yeah I meant more generally the logic moved but not verbatim. On a suggestion from DavidB it uses the extension manager when invoking providers as well as inlines the IsBetter method.

//
// Then invoking sig help will only show the items for "new Bar(" and not also
// the items for "Goo(..."
if (bestItems is not null && items.ApplicableSpan.Start < bestItems.ApplicableSpan.Start)
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the moved IsBetter method logic inlined.

var extensionManager = document.Project.Solution.Services.GetRequiredService<IExtensionManager>();

ISignatureHelpProvider? bestProvider = null;
SignatureHelpItems? bestItems = null;
Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, yeah I meant more generally the logic moved but not verbatim. On a suggestion from DavidB it uses the extension manager when invoking providers as well as inlines the IsBetter method.

@@ -174,66 +176,6 @@ private static bool DisplayPartsMatch(SignatureHelpItem i1, SignatureHelpItem i2

private static bool CompareParts(TaggedText p1, TaggedText p2)
=> p1.ToString() == p2.ToString();

private static async Task<(ISignatureHelpProvider provider, SignatureHelpItems items)> ComputeItemsAsync(
Copy link
Member Author

Choose a reason for hiding this comment

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

I will do a better job of this going forward. Added comments below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Intellisense does not show signature for nested function call
5 participants