Skip to content

Commit

Permalink
Account for new complex AwaitCompletionProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeRobich committed Jul 27, 2021
1 parent cd14f70 commit f4a6654
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ internal static partial class CompletionListBuilder
{ WellKnownTags.Warning, CompletionItemKind.Text },
};

internal const string AwaitCompletionProvider = "Microsoft.CodeAnalysis.CSharp.Completion.Providers.AwaitCompletionProvider";
internal const string ObjectCreationCompletionProvider = "Microsoft.CodeAnalysis.CSharp.Completion.Providers.ObjectCreationCompletionProvider";
internal const string OverrideCompletionProvider = "Microsoft.CodeAnalysis.CSharp.Completion.Providers.OverrideCompletionProvider";
internal const string PartialMethodCompletionProvider = "Microsoft.CodeAnalysis.CSharp.Completion.Providers.PartialMethodCompletionProvider";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ internal static partial class CompletionListBuilder
var seenUnimportedCompletions = false;
var commitCharacterRuleCache = new Dictionary<ImmutableArray<CharacterSetModificationRule>, IReadOnlyList<char>>();
var commitCharacterRuleBuilder = new HashSet<char>();
var isOverrideOrPartialCompletion = completions.Items.Length > 0
&& completions.Items[0].GetProviderName() is OverrideCompletionProvider or PartialMethodCompletionProvider;

for (int i = 0; i < completions.Items.Length; i++)
{
Expand All @@ -51,23 +49,26 @@ internal static partial class CompletionListBuilder
// The completion is somehow expensive. Currently, this one of two categories: import completion, or override/partial
// completion.
Debug.Assert(completion.GetProviderName() is OverrideCompletionProvider or PartialMethodCompletionProvider
or TypeImportCompletionProvider or ExtensionMethodImportCompletionProvider);
or TypeImportCompletionProvider or ExtensionMethodImportCompletionProvider
or AwaitCompletionProvider);

changeSpan = typedSpan;

if (isOverrideOrPartialCompletion)
switch (completion.GetProviderName())
{
// For override and partial completion, we don't want to use the DisplayText as the insert text because they contain
// characters that will affect our ability to asynchronously resolve the change later.
insertText = completion.FilterText;
sortText = GetSortText(completion, labelText, expectingImportedItems);
hasAfterInsertStep = true;
}
else
{
insertText = completion.DisplayText;
sortText = '1' + completion.SortText;
seenUnimportedCompletions = true;
case OverrideCompletionProvider or PartialMethodCompletionProvider or AwaitCompletionProvider:
// For override and partial completion, we don't want to use the DisplayText as the insert text because they contain
// characters that will affect our ability to asynchronously resolve the change later.
insertText = completion.FilterText;
sortText = GetSortText(completion, labelText, expectingImportedItems);
hasAfterInsertStep = true;
break;

default: // case TypeImportCompletionProvider or ExtensionMethodImportCompletionProvider:
insertText = completion.DisplayText;
sortText = '1' + completion.SortText;
seenUnimportedCompletions = true;
break;
}
}
else
Expand Down

0 comments on commit f4a6654

Please sign in to comment.