fix: Add check before show signature help#80945
Open
sami-daniel wants to merge 3 commits intodotnet:mainfrom
Open
fix: Add check before show signature help#80945sami-daniel wants to merge 3 commits intodotnet:mainfrom
sami-daniel wants to merge 3 commits intodotnet:mainfrom
Conversation
Add a check before displaying Signature Help by verifying if we are inside a lambda block so the signature is shown correctly only when appropriate.
| private static bool IsPositionInLambdaBlock(SyntaxNode root, int position) | ||
| { | ||
| var token = root.FindToken(position); | ||
| var lambda = token.Parent?.AncestorsAndSelf().OfType<LambdaExpressionSyntax>().FirstOrDefault(); |
Contributor
There was a problem hiding this comment.
Should probably be AnonymousMethodExpressionSyntax
Contributor
Author
There was a problem hiding this comment.
| void M1(Action a) { } | ||
| void M2() | ||
| { | ||
| M1(() => |
Contributor
There was a problem hiding this comment.
Can you add tests for a=> and then an anonymous delegate as well.
… lambda expression and statementes, including parenthesized and anonymous block
| private static TextSpan? GetSyntaxSpan(SyntaxNode? node) | ||
| { | ||
| var ancestors = node?.AncestorsAndSelf(); | ||
| var lambda = ancestors?.OfType<LambdaExpressionSyntax>().FirstOrDefault(); |
Contributor
There was a problem hiding this comment.
You can use the common super type of these types just once. Greatly simplifying things
Now is using a super type for it called AnonymousFunctionExpressionSyntax, reducing the nescessary code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Add a check before displaying Signature Help by verifying if we are inside a lambda block so the signature is shown correctly only when appropriate.
This pull request addresses an issue where signature help was incorrectly triggered inside the body of lambda expressions in C#.
The main change is to prevent signature help from appearing when the cursor is inside a lambda block, improving the user
experience in scenarios involving lambdas. The update includes both the implementation of the fix and an associated unit test to verify the new behavior.
Signature Help Behavior Improvements:
SignatureHelpUtilitiesto detect when the cursor is inside a lambda block and prevent signature help from appearing in these cases. [1] [2]Testing:
NoSignatureHelpInsideLambdaBlockinInvocationExpressionSignatureHelpProviderTests.csto ensure signature help is not triggered inside lambda blocks.Fixes dotnet/vscode-csharp#8852