Skip to content

Fix caret affinity in GetReferencedSymbolsToLeftOfCaretAsync#52245

Merged
sharwell merged 6 commits intodotnet:release/dev16.10from
sharwell:snippet-before-semicolon
Mar 30, 2021
Merged

Fix caret affinity in GetReferencedSymbolsToLeftOfCaretAsync#52245
sharwell merged 6 commits intodotnet:release/dev16.10from
sharwell:snippet-before-semicolon

Conversation

@sharwell
Copy link
Contributor

@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
@ghost ghost added the Area-IDE label Mar 30, 2021
@sharwell sharwell force-pushed the snippet-before-semicolon branch from 5bd566b to d10df88 Compare March 30, 2021 01:56
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
Contributor 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.

{
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
Contributor 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
Contributor

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