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

Fix caret affinity in GetReferencedSymbolsToLeftOfCaretAsync #52245

Merged
merged 6 commits into from
Mar 30, 2021

Conversation

sharwell
Copy link
Member

@sharwell sharwell commented Mar 30, 2021

Currently argument completion does not work for the following scenario:

await MethodAsync();
  1. Place the caret before ;
  2. Type ConfigureAwait
  3. Press Tab, Tab

This change fixes caret affinity to allow it to work.


There are now two additional bug fixes in this pull request:

  1. It is now possible to use argument completion when calling object.Equals (previously the code would insert the Equals snippet, which made no sense at this location)
  2. It is now possible to use argument completion for constructor calls (previously the code would fail to recognize that constructors have the name .ctor, and dismiss the session before providing arguments)

@sharwell sharwell requested a review from a team as a code owner March 30, 2021 01:49
Copy link
Member

@jasonmalinowski jasonmalinowski left a comment

Choose a reason for hiding this comment

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

Good but the "two different types of method names" thing does look a bit funky. If that can be simplified do it, otherwise if it needs to be different a comment would be good.

/// </summary>
public void ResetOptions()
{
ResetOption(CompletionOptions.EnableArgumentCompletionSnippets);
Copy link
Member

Choose a reason for hiding this comment

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

Rather than calling this one out specifically, I think we can reset generally through the option service. This is the one reason option keys themselves get exported, to allow a general reset.

Copy link
Member Author

Choose a reason for hiding this comment

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

We can, but I encountered problems with it last time I tried. Am reserving that [highly desired] change for a separate PR.

@@ -541,7 +541,7 @@ private bool TryInsertArgumentCompletionSnippet(SnapshotSpan triggerSpan, Snapsh
if (expansion.InsertSpecificExpansion(doc, textSpan, this, LanguageServiceGuid, pszRelativePath: null, out _state._expansionSession) == VSConstants.S_OK)
{
Debug.Assert(_state._expansionSession != null);
_state._methodNameForInsertFullMethodCall = methodName;
_state._methodNameForInsertFullMethodCall = methodSymbols.First().Name;
Copy link
Member

Choose a reason for hiding this comment

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

It's a bit odd that we have two ways we get the method name, one from symbols (which is correct) and the other one which maybe isn't. Should we just initialize methodName this way on 535? Or if it's not the same sometimes, add a comment?

Copy link
Member Author

Choose a reason for hiding this comment

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

💭 One is the method name as it appears in source code, and the other is the method name as it appears in the symbol.

Copy link
Member

Choose a reason for hiding this comment

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

soundsl ike we should prefer the former? (but i don't care much).

Copy link
Member

@jasonmalinowski jasonmalinowski left a comment

Choose a reason for hiding this comment

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

:shipit:

@sharwell sharwell enabled auto-merge March 30, 2021 19:37
@sharwell sharwell merged commit dcb3719 into dotnet:release/dev16.10 Mar 30, 2021
@sharwell sharwell deleted the snippet-before-semicolon branch March 31, 2021 00:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants